网上找的示例,试验成功,如果不成功,可能公司网络的原因。
用到的模块如果还没安装,可以通过以下命令安装相关模块
#perl -MCPAN -e shell
#cpan>install Net::SMTP_auth

use strict;
use MIME::Lite;
use MIME::Base64;
use Authen::SASL;
sub Sendmail {
  my $from = 'xxxxxx@sina.com';
  my $passwd = '*******';
  my $to = 'xxxxxxx@qq.com';
  my $subject  = 'mail subject';
  my $messages = 'messgage'; 
 
  my $msg = MIME::Lite->new(
       From     =>  $from,
       To       =>  $to,
       Subject  =>  $subject,
       Type     =>  'TEXT',
       Data     =>  $messages,
   ); 

  MIME::Lite->send('smtp','smtp.sina.com',  
  Debug     =>'1',
    AuthUser  =>$from,
    AuthPass  =>$passwd,
  ); 

  $msg->send;
}
Sendmail();

标签: none

添加新评论