zoukankan      html  css  js  c++  java
  • tp5 发送smtp邮箱

      

    /**
     * create by wuzicheng
     * author wuzicheng
     * date 20190508
     * 邮件模型类
     *
     **/
    
    namespace appcommonmodel;
    
    
    use PHPMailerPHPMailerException;
    use PHPMailerPHPMailerPHPMailer;
    use thinkLog;
    
    
    class Mail {
     
        //发送邮件  http://www.gzouri.cn/ourui/feedback/index.html
            public function email()
            {
                $mail = new PHPMailer(true);
                $mail->CharSet = "UTF-8";
                try {
            // 服务器设置
                    $mail->SMTPDebug = 2; // 开启Debug
                    $mail->isSMTP(); // 使用SMTP
                    $mail->Host = 'smtp.163.com'; // 服务器地址
                    $mail->SMTPAuth = true; // 开启SMTP验证
                    $mail->Username = ''; // SMTP 用户名(你要使用的邮件发送账号)
                    $mail->Password = ''; // SMTP 密码
                    $mail->SMTPSecure = 'ssl'; // 开启TLS 可选
                    $mail->Port = 465; // 端口
            // 收件人
                    $mail->setFrom('gzouri@163.com'); // 来自
                    $mail->addAddress('365458251@qq.com'); // 可以只传邮箱地址
            // 内容
                    $mail->isHTML(true); // 设置邮件格式为HTML
                    $mail->Subject = '广州欧日机电制造有限公司'; //邮件标题
                    $mail->Body = '浪博游戏是中国最领先的游戏平台'; //邮件内容
                    $mail->send();
                    echo '邮件发送成功。<br>';
                } catch (Exception $e) {
                    echo '邮件发送失败。<br>';
                    echo 'Mailer Error: ' . $mail->ErrorInfo;
                }
            }
    
    }
    

      

  • 相关阅读:
    ubuntu中,终端命令行快速打开html文件方法
    Python清空文本内容的两种方法
    科大教学日历
    MJ瀑布流学习笔记
    iOS搜索框
    异步IO
    yield
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
    15个常用的javaScript正则表达式
    Linux 升级 Python 至 3.x
  • 原文地址:https://www.cnblogs.com/yanyanyanyanliu/p/11466785.html
Copyright © 2011-2022 走看看