Re: Send email using SMTP

[email protected] (Gunnar Hjalmarsson) Thu, 08 Jan 2009 00:50:34 +0100
Newsgroups perl.beginners.cgi
Message-ID <[email protected]>
Adam Jimerson wrote:
>> I solved my problem using the sendmail with the code below in my script:
>>
>> open (MAIL, "|/usr/sbin/sendmail -t ");
>> print MAIL "From: someaddres\@somedomain\n";
>> print MAIL "To: someaddress\@somedomain\n";
>> print MAIL "Content-Type: text/plain\n";
>> print MAIL "Subject: Very simple email test\n\n";
>> print MAIL "Body of the message";
>> close (MAIL);
> 
> This is kind of off topic, but are you using the -T switch on your script?  
> When I tried to open "/usr/bin/mail" with that switch on I get a error 
> message about an insecure environment command.

Did it just say "insecure environment"? On my box it says: "Insecure 
$ENV{PATH} ...", which means that you need to untaint the $ENV{PATH} 
variable. The easiest way to do that is:

     $ENV{PATH} = '';

Please read more about Perl security in "perldoc perlsec".

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