Skip to content

Instantly share code, notes, and snippets.

@numberwhun
Created November 28, 2011 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save numberwhun/1399644 to your computer and use it in GitHub Desktop.
Save numberwhun/1399644 to your computer and use it in GitHub Desktop.
Send Email with Perl
use Net::SMTP;
$smtp = Net::SMTP->new('here.com'); # connect to an SMTP server
$smtp->mail( 'user\@here.com' ); # use the sender's address here
$smtp->to('user\@there.com'); # recipient's address
$smtp->data(); # Start the mail
# Send the header.
$smtp->datasend("To: user\@there.com\n");
$smtp->datasend("From: user\@here.com\n");
$smtp->datasend("\n");
# Send the body.
$smtp->datasend("Hello, World!\n");
$smtp->dataend(); # Finish sending the mail
$smtp->quit; # Close the SMTP connection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment