Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Created script to send email but ending up with blank "FROM" field?

by iburrell (Chaplain)
on Sep 17, 2004 at 21:36 UTC ( [id://391904] : note . print w/replies, xml ) Need Help??


in reply to Re: Created script to send email but ending up with blank "FROM" field?
in thread Created script to send email but ending up with blank "FROM" field?

No surprise it doesn't work; it doesn't compile. You were on the right path in the first code. Just send the complete email message with datasend. Most importantly, send the header with To:, From:, Subject:, and blank line separating it from the body.
use strict; use Net::SMTP; my $sender = $ENV{USER}; my $recipient1 = 'john@hotmail.com'; my $smtp = Net::SMTP->new('mailhost.com'); $smtp->mail($sender); $smtp->recipient($recipient1); $smtp->data(); $smtp->datasend("To: $recipient1"); $smtp->datasend("From: $sender"); $smpt->datasend("Subject: some subject"); $smtp->datasend(""); $smtp->datasend("This is the body"); $smtp->datasend(""); $smtp->quit;
  • Comment on Re^2: Created script to send email but ending up with blank "FROM" field?
  • Download Code