0
SMTP connect() failed PHPmailer - PHPと同じ問題が発生しています。PHPで電子メールを送信する方法
public function sendEmail($toAddress, $subject, $message)
{
require 'PHPMailer-master/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'username';
$mail->Password = 'password';
$mail->SMTPSecure = 'tls';
$mail->SMTPDebug = 2;
$mail->Port = 587;
$mail->setFrom('[email protected]', 'Tripmatcher Support');
$mail->addAddress($toAddress);
$mail->Subject = $subject;
$mail->Body = $message;
if (!$mail->send()) {
error_log('Mailer Error: ' . $mail->ErrorInfo);
} else {
error_log('Email has been sent.');
}
}
2つの質問:次のように私のコードがある
- 私は自分のコードが正しく見える見ることができる、と私はまた私のメールアドレスのために安全性の低いアプリケーションを有効にしている限り、ここで何が間違っています?
- [Mon Sep 18 21:01:43.342766 2017] [:error] [pid 22052] [クライアント2.28.76.119:55132]メーラーエラー:SMTP connect()が失敗しました。 https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting、referer:
これはログに表示されているすべてのものですが、どのようにわかりやすいエラーメッセージが表示されますか?私は同様の質問を見てみましたが、問題が何であるかはまだ分かりません。
質問に記載されているページをお読みになりましたか?特にhttps://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting#smtp-error-could-not-connect-to-smtp-hostとhttps://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting#enabling -debug-output parts – Nima
dig + short smtp.gmail.com gmail-smtp-msa.l.google.com。 64.233.184.108 64.233.184.109 –
これは私がdig + short smtp.gmail.comから得たもので、私のSSLはGoDaddyではないので、その2つのどちらでもないと思います。 –