1、发送给多个收件人,同时抄送给多个人;
2、添加附件;
3、发件人姓名和邮件主题乱码;
4、邮件正文为html格式
public function sendEmail($email=[], $ccEmail=[]) {vendor('PHPMailer.PHPMailer.PHPMailerAutoload');$mail = new \PHPMailer();$mail->IsSMTP(); // 启用SMTP$mail->CharSet = 'utf8'; //设置邮件编码$mail->Host = \"大众smtp.163.com\"大众; //smtp做事器的名称(QQ邮箱为 smtp.exmail.qq.com)$mail->Port = 465;$mail->SMTPAuth = true; //config('MAIL_SMTPAUTH'); //启用smtp认证$mail->Username = \公众xx@163.com\"大众; //你的邮箱名$mail->Password = \"大众xxxx\"大众; //163授权码不是邮箱密码,qq为邮箱密码$mail->SMTPSecure = 'ssl';$mail->From = \"大众from@xx.com\"大众; //发件人地址(也便是你的邮箱地址) //发件人姓名 把稳转码使中文不乱码$mail->FromName = \"大众=?utf-8?B?\公众.base64_encode(\"大众xxx\"大众).\"大众?=\"大众; //多收件人foreach($email as $e){$mail->AddAddress($e);}//多抄送人foreach($ccEmail as $e){$mail->addCC($e);}$mail->AddAttachment('./aa.xlsx','我的附件.xls'); // 添加附件,并指定名称 $mail->AddAttachment('./aa.xlsx','我的附件1.xls');//多附件可以数组循环$mail->WordWrap = 50; //设置每行字符长度$mail->IsHTML(true); // 是否HTML格式邮件 //邮件主题 把稳转码使中文不乱码 $mail->Subject = \"大众=?utf-8?B?\公众.base64_encode(\"大众title\"大众).\"大众?=\"大众; $mail->Body = '你好, <b>朋友</b>! <br/>这是一封来自<a href=\"大众http://www.baidu.com\"大众 target=\公众_blank\"大众>baidu.com</a>的邮件!
<br/>';$mail->AltBody = \公众\"大众;if (!$mail->send()) {return ['code'=>0,'msg'=>$mail->ErrorInfo];} else { return ['code'=>1,'msg'=>'success'];}}