tp5 发送邮件

 
        // 发票主题和内容
        $subject = '您收到一张【】开具的发票【发票号码:' . $res['invoice_num'] . '】';
        $body = '<head><base target="_blank" /><style type="text/css">::-webkit-scrollbar{ display: none; }</style><style id="cloudAttachStyle" type="text/css">#divNeteaseBigAttach, #divNeteaseBigAttach_bak{display:none;}</style><style id="blockquoteStyle" type="text/css">blockquote{display:none;}</style></head><body tabindex="0" role="listitem"><div id="content" style="margin-top: 0px;"><div><table align="center" cellspacing="0" cellpadding="0" style="width: 600px;border: 1px solid #9B9B9B;"><tbody><tr><td style="background: url;"><img src="https://inv.jss.com.cn/group1/M00/5F/0F/wKgHPloTv2GAdu89AADUTKV9lz0494.jpg" width="606" height="120"></td></tr><tr><td><table width="536" style="padding-left: 32px;padding-right: 32px;"><tbody><tr><td style="padding-top: 18px; font-size: 14px; color: #000000;family: Arial, Helvetica, sans-serif;"><span>尊敬的客户,您好!</span></td></tr><tr><td style="padding-top: 24px; font-size: 14px; color: #000000;family: Arial, Helvetica, sans-serif;"><span>您于2019年11月11日消费并开具了增值税电子发票,<a style="text-decoration: none;color: #2674D4;" href="' . $res['invoice_file_url'] . '">查看发票</a>。</span></td></tr><tr><td><table width="536" style="background-color: #EEF0F3;padding-top: 18px;padding-left: 25px;padding-bottom: 20px;border: 1px solid #CBD1DA;"><tbody><tr><td style="font-size: 14px;max-width: 503px;word-break: break-all;" colspan="2"><span><b>购方名称:</b><span style="color: #2674D4;"><b>' . $res['name'] . '</b></span></span></td></tr><tr><td style="font-size: 14px;"><span><b>开票日期:</b><span style="color: #2674D4;"><b>2019年11月11日</b></span></span></td><td style="font-size: 14px;"><span><b>合计金额:</b><span style="color: #2674D4;"><b>¥0.01</b></span></span></td></tr><tr><td style="font-size: 14px;"><span><b>发票代码:</b><span style="color: #2674D4;"><b>131880930142</b></span></span></td><td style="font-size: 14px;"><span><b>发票号码:</b><span style="color: #2674D4;"><b>' . $res['invoice_num'] . '</b></span></span></td></tr><tr><td style="font-size: 14px;max-width: 503px;word-break: break-all;" colspan="2"><span><b>PDF地址:</b><b><a href="' . $res['invoice_file_url'] . '" style="text-decoration: none;color: #2674D4;">' . $res['invoice_file_url'] . '</a></b></span></td></tr></tbody></table></td></tr>
<tr style="height:100px;line-height: 100px;"><td style="font-size: 14px;"><span>此致</span></td></tr></tbody></table></td></tr></tbody></table><p style="text-align: center;font-size: 12px;line-height: 20px;color: #4A4A4A;margin-top: 50px">本邮件由系统自动发送,请勿直接回复</p></div></div><script>var _c=document.getElementById(\'content\');_c.innerHTML=(_c.innerHTML||\'\').replace(/(href|formAction|onclick|javascript)/ig, \'__$1\').replace(/<\/?marquee>/ig,\'\');</script><style type="text/css">body{font-size:14px;font-family:arial,verdana,sans-serif;line-height:1.666;padding:0;margin:0;overflow:auto;white-space:normal;word-wrap:break-word;min-height:100px}td, input, button, select, body{font-family:Helvetica, \'Microsoft Yahei\', verdana}pre {white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word;width:95%}th,td{font-family:arial,verdana,sans-serif;line-height:1.666}img{ border:0} header,footer,section,aside,article,nav,hgroup,figure,figcaption{display:block} blockquote{margin-right:0px}</style><style id="ntes_link_color" type="text/css">a,td a{color:#064977}</style></body>';
        $mail = new \PHPMailer();           //实例化PHPMailer对象
        $mail->CharSet = 'UTF-8';           //设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置,否则乱码
        $mail->IsSMTP();                    // 设定使用SMTP服务
        $mail->SMTPDebug = 0;               // SMTP调试功能 0=关闭 1 = 错误和消息 2 = 消息
        $mail->SMTPAuth = true;             // 启用 SMTP 验证功能
        $mail->SMTPSecure = 'ssl';          // 使用安全协议
        $mail->Host = "smtp.qq.com"; // SMTP 服务器
        $mail->Port = 465;                  // SMTP服务器的端口号
        $mail->Username = "523566228";    // SMTP服务器用户名
        $mail->Password = "xtgjabszmptybjif";     // SMTP服务器密码
        $mail->SetFrom('[email protected]');
        $replyEmail = '';                   //留空则为发件人EMAIL
        $replyName = '';                    //回复名称(留空则为发件人名称)
        $mail->AddReplyTo($replyEmail, $replyName);
        $mail->Subject = $subject;
        $mail->MsgHTML($body);
        $mail->AddAddress($res['email']);
        if (isset($attachment) && is_array($attachment)) { // 添加附件
            foreach ($attachment as $file) {
                is_file($file) && $mail->AddAttachment($file);
            }
        }
        $result = $mail->send();
        if ($result) {
            $this->success('发送成功');
        } else {
            $this->error('发送失败');
        }
发布了68 篇原创文章 · 获赞 10 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/dw5235/article/details/103047048
今日推荐