以下功能发送电子邮件但收到任何邮件或错误:
function send_Email($email, $subject, $body ,$cc = '')
{
$this->Log("Sending email with To: ". $email. " <br>Subject: ". $subject ." <br>Body: ".$body);
$mail = new PHPMailer();
$mail->IsHTML(true);
$mail->IsSMTP();
$mail->CharSet = "utf-8";
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Host = email_host;
$mail->Username = email_username;
$mail->Password = email_password;
$mail->SetFrom('support@xyv.com', 'zzz Support');
$mail->AddReplyTo('support@xyv.com', 'zzz Support');
$mail->AddAddress($email);
$mail->AddBCC('support@xyv.com');
$mail->AddBCC('zzz@zzz.com');
if(!empty($cc)) {
$mail->addCC($cc);
}
$mail->Subject = $subject;
$mail->Body = $body;
echo "<pre>"; print_r($mail);echo "</pre>";
$response = $mail->Send();
var_dump($response);
return $response;
}
调试:在调试模式下没有获得错误 [error_count:protected] =&gt; 0
答案 0 :(得分:0)
阅读文档并将代码基于所提供的示例,这将显示如何获取有关错误的信息并显示调试输出,这将非常有帮助。你没有得到任何输出,因为你没有要求任何输出。从自述文件中的示例:
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
这将显示发送失败的原因。要启用SMTP调试输出,请执行以下操作:
$mail->SMTPDebug = 2;