我正在尝试发送邮件,但它只是将我带到了空白页面。回声没有被击中,我看不到错误。
try {
$mail->SetFrom($email, $name);
$mail->SMTPDebug = 2;
$address = "xx@gmail.com";
$mail->AddAddress($address, "xx");
$mail->Subject = "Contact Form Submission | " . $name;
$mail->MsgHTML($email_body);
$mail->SMTPSecure = "tls";
$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = 'xx@gmail.com';
$mail->Password = 'password1234';
if (!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
else
echo 'sent';
//header("Location: contact.php?status=thanks");
} catch (phpmailerException $e) {
echo 'error1';
} catch (Exception $e) {
echo 'error2';
}