1
以下代碼用於使用phpmailer函數和amazon ses ec2發送電子郵件,如果我使用不同的端口(25,465,587),則會得到不同的錯誤。使用amazon ses ec2發送電子郵件錯誤
<?php
require 'class.phpmailer.php';
$to = "********@gmail.com";
$from = "[email protected]"; // verified mail id
$subject = "a test subject";
$body = "email body content goes here";
$mail = new PHPMailer();
$mail->IsSMTP(true); // use SMTP
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "email-smtp.us-west-2.amazonaws.com"; // Amazon SES server, note "tls://" protocol
$mail->Port = 465; // set the SMTP port
$mail->Username = "*************"; // SES SMTP username
$mail->Password = "*****************"; // SES SMTP password
$mail->SetFrom($from, 'First Last');
$mail->AddReplyTo($from,'First Last');
$mail->Subject = $subject;
$mail->MsgHTML($body);
$address = $to;
$mail->AddAddress($address, $to);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
我收到以下錯誤
SMTP -> FROM SERVER:
SMTP -> FROM SERVER:
SMTP -> ERROR: EHLO not accepted from server:
SMTP -> FROM SERVER:
SMTP -> ERROR: HELO not accepted from server:
SMTP -> ERROR: AUTH not accepted from server:
SMTP -> NOTICE: EOF caught while checking if connectedSMTP Error: Could not authenticate. Mailer Error: SMTP Error: Could not authenticate.
我寫的錯誤在我的代碼?
錯誤消息表明您的身份驗證(用戶名,密碼)不正確。 – tedder42 2015-03-31 15:52:49
顯示的輸出實際上是無用的。我建議將debug設置爲4.另外,您需要SMTPSecure ='tls',並且可能最正確的端口是465,它希望您從開始時打開tls連接,而不是使用「STARTTLS」,儘管從模塊文檔。取決於模塊如何處理加密,465或587將是正確的選擇。 – 2015-04-01 00:43:21
現在它的作品,,, – karthik 2015-04-04 07:26:12