perl Mail::Sender模塊發送郵件


 1 #!/usr/bin/perl -w
 2 use strict;
 3 use Mail::Sender;
 4  
 5 my $count = 1;
 6 while(1){
 7 my $sender = Mail::Sender->new({
 8     smtp => 'smtp.163.com',
 9         #這里以163為例
10     from => '這里寫你的163郵箱地址:username@163.com',
11     auth => 'LOGIN',
12     authid => '這里寫你的163郵箱用戶名:username',
13     authpwd => '這里寫你的郵箱密碼:password'}
14 ) or die "Cannot send mail:$!\n";
15  
16 my $messages = 'hello這里是要發送的內容';
17  
18     $sender->MailMsg({
19         to => '要發送到哪個郵箱:test@qq.com',
20         subject => '郵箱標題',
21         msg => $messages}
22     );
23 $sender->Close();
24 print "第$count封發送完畢!\n";
25 $count++;
26 }

這里用了一個while(1)測試一直發送
perl默認沒有安裝Mail::Sender模塊, 要自行安裝

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM