Created
November 28, 2011 08:39
-
-
Save numberwhun/1399644 to your computer and use it in GitHub Desktop.
Send Email with Perl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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