通过smtp验证发送邮件的perl脚本

#!/usr/bin/perl -w
use strict;
use Net::SMTP;
use Authen::SASL;
BEGIN {
push (@INC,'/usr/lib/perl5/5.8.8/Net/ ');
}
my $from = '[email protected]';
my $date = '2012-03-15 23:20:22';
my $to = '[email protected]';
my $username = '[email protected]';
my $passwd = 'lubing';
my $subject = 'beisen is ok';
my $smtp = Net::SMTP->new('mail.beisen.cn');
$smtp->auth($username,$passwd) or die "Could not authenticate $!";
$smtp->mail($from);
$smtp->to($to);
$smtp->data();
$smtp->datasend("Date:$date\n");
$smtp->datasend("From:$from\n");
$smtp->datasend("To: $to\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("fdjklasjdflksdajflkjsdaklfjsalkjkidfjklasjflksdaj");
$smtp->dataend();

$smtp->quit;

本文出自 “决胜千里之外” 博客,谢绝转载!

你可能感兴趣的:(脚本,perl,发送邮件)