我想使用 PHPMailer 发送没有 SSL 的电子邮件。我已启用调试模式,以便我可以检查日志中的详细信息。
$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail->IsSMTP(true); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = false; // secure transfer enabled REQUIRED for Gmail
$mail->Host = "mail.company.co.uk";
$mail->Port = 25; // or 587
$mail->IsHTML(true);
$mail->Username = "email@company.co.uk";
$mail->Password = "password_of_username";
$mail->SetFrom($email,$name);
$mail->Subject = $subject;
$mail->Body = $message;
$mail->AddAddress($to);
这是一个例外:
2018-09-28 10:04:27 CLIENT -> SERVER: EHLO localhost<br>
2018-09-28 10:04:27 CLIENT -> SERVER: STARTTLS<br>
SMTP Error: Could not connect to SMTP host.<br>
2018-09-28 10:04:28 CLIENT -> SERVER: QUIT<br>
2018-09-28 10:04:28 <br>
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting<br>
Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting