12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- namespace app\common\util;
- use PHPMailer\PHPMailer\Exception;
- use PHPMailer\PHPMailer\PHPMailer;
- class Email
- {
- public function sendEmail($toEmail, $tp): int
- {
- $mail = new PHPMailer();
- $mail->isSMTP();
- $mail->CharSet = "utf8";
- $mail->Host = "smtp.qq.com";
- $mail->SMTPAuth = true;
- $mail->Username = "845178954@qq.com";
- $mail->Password = "dptntlmpifkqbfgb";
- $mail->SMTPSecure = "ssl";
- $mail->Port = 465;
- try {
- $mail->setFrom("845178954@qq.com", "皮编程");
- } catch (Exception $e) {
- }
- try {
- $mail->addAddress($toEmail, '教务');
- } catch (Exception $e) {
- }
- try {
- $mail->addReplyTo("845178954@qq.com", "皮编程");
- } catch (Exception $e) {
- }
-
-
-
- $mail->isHTML();
- $mail->Subject = "【商品发货通知】";
- try {
- $mail->MsgHTML($tp);
- } catch (Exception $e) {
- }
-
- if (!$mail->send()) {
-
- return 400;
- } else {
- return 200;
- }
- }
- public function getTp($phone, $goodsname, $goodstype, $num, $price, $total_amount, $status_text, $password = ''): string
- {
- return '<!DOCTYPE html>
- <html lang="">
- <head>
- <title></title>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <style>
- table{
- border: 1px solid red;
- }
- </style>
- </head>
- <body>
- <div class="container mt-3">
- <h2>订单信息: </h2>
- <h5>账号: ' . $phone . '</h5>
- <h5>商品: ' . $goodsname . '</h5>
- <h5>类型: ' . $goodstype . '</h5>
- <h5>数量: ' . $num . '</h5>
- <h5>单价: ' . $price . '</h5>
- <h5>总金额: ' . $total_amount . '</h5>
- <h5>状态: ' . $status_text . '</h5>
- <h5>卡密: ' . $password . '</h5>
- </div>
- </body>
- </html>';
- }
- }
|