加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

perl 发送mail

发布时间:2020-12-15 23:54:21 所属栏目:大数据 来源:网络整理
导读: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/perluse strict;use warnings;use Net::SMTP;use Authen::SASL;my $ma

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: recipientn");
$smtp->datasend("n");
$smtp->datasend("Line1nLine2n");
$smtp->dataend();

$smtp->quit;


3,操作结果



参考:

http://bbs.chinaunix.net/thread-1499038-1-1.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读