Mega Code Archive

 
Categories / Perl / Network
 

Send mail

use Net::SMTP; print "Content-type:text/html\n\n"; my $relay="relay.demo.net"; my $smtp="Net::SMTP->new($relay); die "Could not open connection: $!" if (! defined $smtp); $smtp->mail("Bate"); $smtp->to("admin@demo.net"); $smtp->data(); $smtp->datasend("To: admin@demo.net\n"); $smtp->datasend("From: admin@demo.net\n"); $smtp->datasend("Subject: Test1"); $smtp->datasend("\n"); $smtp->datasend("This is a test ...\n"); $smtp->dataend(); $smtp->quit; print "Completed ...\n";