http://qs1969.pair.com?node_id=391904


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;