#!/usr/local/bin/perl -wT
use Net::SMTP;
print "Content-type: text/plain", "\n\n";
my $DEBUG = 1;
if ($DEBUG)
{
$| = 1;
open(STDERR, ">&STDOUT");
}
# smtp server name
my $serverName = "mail.blah.com";
# create a new smtp object
$smtp = Net::SMTP->new($serverName, Debug => 1);
# if you can't connect then dont proceed with the rest of the script
die "Couldn't connect to server" unless $smtp;
# initiate the mail transaction
# your "real" email address
my $from = "crap\@blah.com";
# recipient's "real" email address
my $to = "poop\@toilet.com";
$smtp->mail($from);
$smtp->to($to);
# start the mail
$smtp->data();
# send the header
# this address will appear in the message
$smtp->datasend("To: poop\@toilet.com\n");
# so will this one
$smtp->datasend("From: crap\@blah.com\n");
$smtp->datasend("Subject: Online Ordering Test Message\n");
$smtp->datasend("\n");
# send the body
$smtp->datasend("TESTING TESTING TESTING\n\n");
# send the termination string
$smtp->dataend();
# close the connection
$smtp->quit();
####
Relaying denied. IP name possibly forged
####
Net::SMTP=GLOB(0x8114994)<<< 500 5.5.1 Command unrecognized: "To: poop@toilet.com"
Net::SMTP=GLOB(0x8114994)>>> QUIT
Net::SMTP=GLOB(0x8114994)<<< 500 5.5.1 Command unrecognized: "From: crap@blah.com"