码迷,mamicode.com
首页 > Web开发 > 详细

conposer phpmailer 发邮件

时间:2017-07-12 19:56:13      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:orm   dad   connect   html   body   option   pos   erro   from   

把"phpmailer/phpmailer": "~5.2"放到conposer.json下面

命令行执行conposer update  在vendor下面会出现PHPMailer文件夹

进入vendor/composer/autoload_classmap.php

复制一行

技术分享

写成最后一行,然后控制器use PHPMailer;

$mail = new PHPMailer;

        //$mail->SMTPDebug = 3;                               // Enable verbose debug output

        $mail->isSMTP();                                      // Set mailer to use SMTP
        $mail->Host = ‘smtp.163.com‘;  // Specify main and backup SMTP servers
        $mail->SMTPAuth = true;                               // Enable SMTP authentication
        $mail->Username = ‘18830428521@163.com‘;                 // SMTP username
        $mail->Password = ‘gzp910728‘;                           // SMTP password
        $mail->SMTPSecure = ‘tsl‘;                            // Enable TLS encryption, `ssl` also accepted
        $mail->Port = 25;                                    // TCP port to connect to

        $mail->setFrom(‘18830428521@163.com‘, ‘鹏大哥‘);
        // $mail->addAddress(‘1406002855@qq.com‘, ‘鹏哥哥‘);     // Add a recipient
        $mail->addAddress(‘1406002855@qq.com‘);               // Name is optional
        $mail->addReplyTo(‘1406002855@qq.com‘, ‘鹏哥哥‘);
        // $mail->addCC(‘cc@example.com‘);
        // $mail->addBCC(‘bcc@example.com‘);

        // $mail->addAttachment(‘/var/tmp/file.tar.gz‘);         // Add attachments
        // $mail->addAttachment(‘/tmp/image.jpg‘, ‘new.jpg‘);    // Optional name
        $mail->isHTML(true);                                  // Set email format to HTML

        $mail->Subject = ‘Here is the subject‘;
        $mail->Body    = ‘This is the HTML message body <b>in bold!</b>‘;
        $mail->AltBody = ‘This is the body in plain text for non-HTML mail clients‘;

        if(!$mail->send()) {
            echo ‘Message could not be sent.‘;
            echo ‘Mailer Error: ‘ . $mail->ErrorInfo;
        } else {
            echo ‘Message has been sent‘;
        }

 

conposer phpmailer 发邮件

标签:orm   dad   connect   html   body   option   pos   erro   from   

原文地址:http://www.cnblogs.com/peng0728/p/7157100.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!