PHPMailer发送邮件提示553 Mail from must equal authorized user的原因是SMTP服务器用户名与发件人邮箱不一致,修改成相同即可解决这个问题。
/** *系统邮件发送函数 *@paramstring$tomail接收邮件者邮箱 *@paramstring$name接收邮件者名称 *@paramstring$subject邮件主题 *@paramstring$body邮件内容 *@paramstring$attachment附件列表 *@returnboolean *@authorstatic7<static7@qq.com> */ functionsend_mail($tomail,$name,$subject='',$body='',$attachment=null){ $mail=newPHPMailerPHPMailerPHPMailer(); $mail->CharSet='UTF-8'; $mail->IsSMTP(); $mail->SMTPDebug=0; $mail->SMTPAuth=true; $mail->SMTPSecure='ssl'; $mail->Host="smtp.163.com"; $mail->Port=465; $mail->Username="test@163.com";//SMTP服务器用户名 $mail->Password="******";//SMTP服务器密码与邮箱密码不同 $mail->SetFrom('test@163.com','测试邮件');//此处的邮箱应该与上面的SMTP服务器用户名一致 $replyEmail=''; $replyName=''; $mail->AddReplyTo($replyEmail,$replyName); $mail->Subject=$subject; $mail->MsgHTML($body); $mail->AddAddress($tomail,$name); if(is_array($attachment)){ foreach($attachmentas$file){ is_file($file)&&$mail->AddAttachment($file); } } return $mail->Send()?true:$mail->ErrorInfo; }