-
-
Save jettero/283156 to your computer and use it in GitHub Desktop.
Net::SMTP demo for some solaris people... yonder ...
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
my $smtp = Net::SMTP->new("mail.gateway.company.com", | |
Hello=>"sending-hostname.company.com", Debug=>1) | |
or croak $!; | |
# This is the SMTP Return path. It's the actual return path of the | |
# mail and should be real. It's used in the accept/deny decision | |
# (sometimes) and populates the return-path: header in the email. It's | |
# the MAIL FROM SMTP command. | |
$smtp->mail('[email protected]'); | |
# This is is the RCPT part of the SMTP session. The recipients of the | |
# mail are decided from this command. The body of the message (e.g., | |
# the To: header below) is not used to decide recipients. That's part | |
# of the story you tell the recipient. All TO:, BCC: and CC: | |
# recipients must be listed here. the only difference between a BCC | |
# and a CC is that the BCC won't appear in the body of the message | |
# below. | |
$smtp->to("[email protected]", "[email protected]", "[email protected]"); | |
# send SMTP command to start start the body of the message | |
$smtp->data; | |
# The rest of this can be as fictional as you like. The from: and to: | |
# headers are used by mail clients to show the sender, but the mail | |
# servers don't normally care about them at all. | |
$smtp->datasend("From: \"My Real Name\" <[email protected]>\n"); | |
$smtp->datasend("To: \"someone cool\" <[email protected]>\n"); | |
$smtp->datasend("Subject: whatever...\n"); | |
$smtp->datasend("Reply-To: whatever\n"); | |
# skip one line before the message contents. This tells mail clients | |
# the headers are done and the message is beginning. | |
$smtp->datasend("\n"); | |
# The format of the message headers and the blank line is in RFC2822 | |
# aka Internet Message Format. | |
$smtp->datasend($msg); | |
# end the body of the message and start sending SMTP commands again | |
$smtp->dataend; | |
# SMTP QUIT | |
$smtp->quit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment