#!/usr/bin/perl -w use strict; use Net::SMTP; my $smtp = Net::SMTP->new('mailhost.foo.com'); $smtp->data(); $smtp->datasend("To: user@bar.com\n"); $smtp->datasend("X-Mailer: Random dodgy email script\n"); $smtp->datasend("X-My-Favourite-Whisky: Glenfarclas\n"); # The following newline is the delimiter between the header # and the body. # For more info, on headers and how to form a email # you should read the RFC for SMTP. $smtp->datasend("\n"); # Following line is the message body. $smtp->datasend("If this works, you've got Perl to thank.\n"); $smtp->dataend(); $smtp->quit;