Posted By

fugue on 12/29/06


Tagged


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

luman
icecreamboyy


Send mail SMTP


 / Published in: Perl
 

  1. use Net::SMTP;
  2.  
  3. $smtp = Net::SMTP->new('here.com'); # connect to an SMTP server
  4. $smtp->mail( 'user\@here.com' ); # use the sender's address here
  5. $smtp->to('user\@there.com'); # recipient's address
  6. $smtp->data(); # Start the mail
  7.  
  8. # Send the header.
  9. $smtp->datasend("To: user\@there.com\n");
  10. $smtp->datasend("From: user\@here.com\n");
  11. $smtp->datasend("\n");
  12.  
  13. # Send the body.
  14. $smtp->datasend("Hello, World!\n");
  15.  
  16. $smtp->dataend(); # Finish sending the mail
  17. $smtp->quit; # Close the SMTP connection

Report this snippet  

You need to login to post a comment.