How to send email from perl-script with different priorities : normal

How to send email from perl-script with different priorities : normal

am 10.01.2008 20:02:46 von simon.greenberg

Hello,

I'm trying to send email from my perl-script with different
priorities : normal or high.
For some reasons, I'm not going to use any perl-module like
MIME::Lite.

$email = "my.email\@isp.com";
$priority = 'high';

$html = "MIME-Version: 1.0\nContent-Type: text/html\; charset=us-ascii
\n";
$html .= "Subject: FYI-- $date\n";

$html .= "Priority: $priority\n\n"; # ---> here I'm trying to change
email priority

$html .= "


";
$html .= "

FYI -- $date

\n";
$html .= "
";

open ( MAIL, "|/usr/bin/mail $email") or die;
print MAIL $html;
close ( MAIL);

Thank you in advance,
--Simon

Re: How to send email from perl-script with different priorities : normal or high

am 10.01.2008 21:01:14 von Keith Keller

On 2008-01-10, sg wrote:
>
> I'm trying to send email from my perl-script with different
> priorities : normal or high.
> For some reasons, I'm not going to use any perl-module like
> MIME::Lite.
>
> $email = "my.email\@isp.com";
> $priority = 'high';
>
> $html = "MIME-Version: 1.0\nContent-Type: text/html\; charset=us-ascii
> \n";
> $html .= "Subject: FYI-- $date\n";
>
> $html .= "Priority: $priority\n\n"; # ---> here I'm trying to change
> email priority
>
> $html .= "


";
> $html .= "

FYI -- $date

\n";
> $html .= "
";
>
> open ( MAIL, "|/usr/bin/mail $email") or die;
> print MAIL $html;
> close ( MAIL);

Do you realize that $html is entirely in the body of your message? You
can't set headers like this. If you're not going to use MIME::Lite, you
might consider using a module like Net::SMTP, where you construct the
whole message, including headers. (You also won't be dependent on the
behavior of /usr/bin/mail, which does vary across implementations.)

--keith


--
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information

Re: How to send email from perl-script with different priorities: normal or high

am 10.01.2008 21:54:07 von Gunnar Hjalmarsson

sg wrote:
> I'm trying to send email from my perl-script with different
> priorities : normal or high.



> open ( MAIL, "|/usr/bin/mail $email") or die;

Try sendmail instead of mail:

open MAIL, "|/usr/sbin/sendmail -t $email" or die $!;

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Re: How to send email from perl-script with different priorities :

am 10.01.2008 23:50:00 von simon.greenberg

On Jan 10, 12:54=A0pm, Gunnar Hjalmarsson wrote:
> sg wrote:
> > I'm trying to send email from my perl-script with different
> > priorities : normal or high.
>
>
>
> > open =A0( MAIL, "|/usr/bin/mail $email") or die;
>
> Try sendmail instead of mail:
>
> open MAIL, "|/usr/sbin/sendmail -t $email" or die $!;
>
> --
> Gunnar Hjalmarsson
> Email:http://www.gunnar.cc/cgi-bin/contact.pl

Thank you all for support. Script works now. What is really important:

1. Format !!! $html .=3D "X-Priority: 1 (Highest)"."\n\n";

2. Both, /usr/bin/mail and /usr/sbin/mail -t are correctly
interpreting "HIGH" priopity parameter.

Cheers,
--Simon

Re: How to send email from perl-script with different priorities: normal or high

am 11.01.2008 00:27:50 von Gunnar Hjalmarsson

sg wrote:
> On Jan 10, 12:54 pm, Gunnar Hjalmarsson wrote:
>> sg wrote:
>>>
>>> open ( MAIL, "|/usr/bin/mail $email") or die;
>>
>> Try sendmail instead of mail:
>>
>> open MAIL, "|/usr/sbin/sendmail -t $email" or die $!;
>
> 2. Both, /usr/bin/mail and /usr/sbin/mail -t are correctly
> interpreting "HIGH" priopity parameter.

[guess you meant to say: /usr/sbin/sendmail]

Funny, I thought that Keith was right in that 'mail' doesn't allow
message headers to be set the way you described.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Re: How to send email from perl-script with different priorities : normal or high

am 11.01.2008 01:10:11 von Keith Keller

On 2008-01-10, Gunnar Hjalmarsson wrote:
>
> Funny, I thought that Keith was right in that 'mail' doesn't allow
> message headers to be set the way you described.

Maybe the OP's does. Mine doesn't. That's also why I said that
/usr/bin/mail varies wildly, and Net::SMTP is a better choice. Using
sendmail is better than using mail, but there's no guarantee that the
system has sendmail. If the script isn't meant to be used on another
machine, fine, but it always seems to happen to me that a script I never
meant for another machine always ends up on another machine.

--keith


--
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information

Re: How to send email from perl-script with different priorities :

am 11.01.2008 22:34:58 von simon.greenberg

On Jan 10, 3:27=A0pm, Gunnar Hjalmarsson wrote:
> sg wrote:
> > On Jan 10, 12:54 pm, Gunnar Hjalmarsson wrote:
> >> sg wrote:
>
> >>> open =A0( MAIL, "|/usr/bin/mail $email") or die;
>
> >> Try sendmail instead of mail:
>
> >> open MAIL, "|/usr/sbin/sendmail -t $email" or die $!;
>
> > 2. Both, /usr/bin/mail and /usr/sbin/mail -t are correctly
> > interpreting "HIGH" priopity parameter.
>
> [guess you meant to say: /usr/sbin/sendmail]
>
> Funny, I thought that Keith was right in that 'mail' doesn't allow
> message headers to be set the way you described.
>
> --
> Gunnar Hjalmarsson
> Email:http://www.gunnar.cc/cgi-bin/contact.pl

yes, you are right - It is a typo - should be /usr/sbin/sendmail

Thank you