zoukankan      html  css  js  c++  java
  • 使用perl发邮件

    如果你使用的是 window 系统,没有 sendmail 工具。这时你就可以使用 perl 的 MIME:Lite 模块作为邮件客户端来发送邮件。

    这里我们直接用 cpan 来安装(需要 root 权限),不用下载:

    $ cpan -i MIME::Lite
    ……
      /usr/bin/make install  -- OK

    文档地址: http://search.cpan.org/~rjbs/MIME-Lite-3.030/lib/MIME/Lite.pm

    还需要安装  cpan -i Net::SMTP 

    use MIME::Lite;
     
    # 接收邮箱,这里我设置为我的 QQ 邮箱,你需要修改它为你自己的邮箱
    $to = '634412144@qq.com';
    # 抄送者,多个使用逗号隔开
    # $cc = 'test1@runoob.com, test2@runoob.com';
     
    #发送者邮箱
    $from = 'qin_zhongbao@163.com';
    #标题
    $subject = '菜鸟教程 Perl 发送邮件测试';
    $message = '这是一封使用 Perl 发送的邮件,使用了 MIME::Lite 模块。';
     
    $msg = MIME::Lite->new(
                     From     => $from,
                     To       => $to,
                     Subject  => $subject,
                     Data     => $message
                     );
     
    $user='qin_zhongbao@163.com';
    $pass = '123456'; 
    
    $res = $msg ->send('smtp', "smtp.163.com",AuthUser=>$user,AuthPass=>$pass);
        if($res){
        print "邮件发送成功
     ";
        }else{
        print "邮件发送失败
     ";
        }    
  • 相关阅读:
    ps入门
    ls命名 | Linux统计文件夹内的文件个数
    python打包成可执行文件
    装饰器
    poj 2752 Seek the Name, Seek the Fame
    字符串最大值
    次小生成树
    Selecting Courses
    poj 3461 Oulipo
    poj 2406 Power Strings
  • 原文地址:https://www.cnblogs.com/qinzb/p/8968569.html
Copyright © 2011-2022 走看看