use strict; use warnings; use Net::SMTP; my $smtp = Net::SMTP->new('MAILSERVER') or die $!; my ($from, $to) = ('blah@domain.com', 'user@otherdomain.com'); my ($subject, $message) = ('Test subject', 'Test message'); $smtp->mail( $from ); $smtp->to( $to ); $smtp->data(); $smtp->datasend("To: $to\n"); $smtp->datasend("From: $from\n"); $smtp->datasend("Subject: $subject\n"); $smtp->datasend("\n"); # done with header $smtp->datasend($message); $smtp->dataend(); $smtp->quit(); # all done. message sent.