12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace Service\Lib;
- use Dever;
- class Email
- {
- public function send()
- {
- $uid = Dever::input('uid');
- $feedback_id = Dever::input('feedback_id');
- $email = Dever::input('email');
- $user = Dever::db('passport/user')->one($uid);
- if ($user['email'] != $email) {
- Dever::db('passport/user')->update(array('where_id' => $uid, 'email' => $email));
- }
- $info = Dever::db('service/feedback')->one($feedback_id);
-
- $product = Dever::db('service/product')->one($info['product_id']);
- //$pdf = Dever::local($info['pdf']);
- $pdf = str_replace('{uploadRes}', Dever::data() . 'upload/', $info['pdf']);
- Dever::apply('src/PHPMailer', 'email');
- Dever::apply('src/Exception', 'email');
- Dever::apply('src/SMTP', 'email');
- $mail = new \PHPMailer\PHPMailer\PHPMailer();
- $mail->isSMTP();
- //$mail->SMTPDebug = 2;
- $mail->CharSet = 'UTF-8';
- $mail->Host = 'smtp.exmail.qq.com';
- $mail->Port = 465;
- $mail->SMTPSecure = 'ssl';
- $mail->SMTPAuth = true;
- $mail->Username = 'miniapps@jiazhihome.com';
- $mail->Password = 'ILoveJiazhi0426';
- $mail->setFrom('miniapps@jiazhihome.com', '家芝服务');
- $mail->addAddress($email, $user['username']);
- $name = '家芝'.$product['name'].'方案';
- $mail->Subject = "=?utf-8?B?" . base64_encode($name) . "?=";
- $mail->Body = '您好,'.$user['username'].',请见附件。';
- $mail->addAttachment($pdf);
- if (!$mail->send()) {
- Dever::alert("Mailer Error: " . $mail->ErrorInfo);
- } else {
- return 'ok';
- }
- }
- }
|