Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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

by edger1 (Initiate)
on Sep 17, 2004 at 18:04 UTC ( [id://391862]=note: print w/replies, xml ) Need Help??


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

Thanks for the help.

The following code doesn't return any errors but I am not getting the email! What is my problem? How do I specify who $env{user} is? Do I say $user = from email address or do I say $envsh{user} = from email address? Below is the code:

use strict; use Net::SMTP; my $recipient1 = 'john@hotmail.com'; my $smtp = Net::SMTP->new('myhost.com' ); #$smtp->mail ($ENV{USER}); To: $recipient1; From: $ENV{USER}; Subject: "A Message"; "Test message to check my code"; $smtp->datasend(); $smtp->quit;
  • Comment on Re: Created script to send email but ending up with blank "FROM" field?
  • Download Code

Replies are listed 'Best First'.
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
    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;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://391862]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-14 04:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found