1,需要的两个主要的lib
http://search.cpan.org/~shay/libnet-1.27/Net/SMTP.pm
http://search.cpan.org/~gbarr/Authen-SASL-2.16/lib/Authen/SASL.pod
2,使用perl发送mail
#!/usr/bin/perl
use strict;
use warnings;
use Net::SMTP;
use Authen::SASL;
my $mailhost = 'smtp.qq.com';
my $mailfrom = 'mailfromxxx@qq.com';
my $mailto = 'mailtoxxx@qq.com';
my $subject = 'subject';
my $content = 'content';
my $smtp = Net::SMTP->new('smtp.qq.com',
Timeout => 30
);
$smtp->auth('username@qq.com','password');
$smtp->mail($mailfrom);
$smtp->to($mailto);
$smtp->data();
$smtp->datasend("To: recipient\n");
$smtp->datasend("\n");
$smtp->datasend("Line1\nLine2\n");
$smtp->dataend();
$smtp->quit;
3,操作结果
参考: