Perl 使用 Net::SMTP 发送邮件

#!c:\perl\bin

use Net::SMTP;

print "Content-type: text/html \n\n";

$server = 'mail.mydomain.com';
$fromaddress = 'me@mydomain.com';
$toaddress = 'you@yourdomain.com';

$subject = "Test Example \n\n";

$message = "This is a test \n\n";

$smtp = Net::SMTP->new($server);

$smtp->mail($fromaddress);
$smtp->to($toaddress);
$smtp->data();
$smtp->datasend("Subject: $subject");
$smtp->datasend($message);
$smtp->dataend();

$smtp->quit();

编程技巧