mardi 31 mars 2015

Sending email error using amazon ses ec2

The following code used to send email using phpmailer function and amazon ses ec2, if i use different port(25, 465, 587) then getting different error.



<?php
require 'class.phpmailer.php';
$to = "********@gmail.com";
$from = "info@itlowers.com"; // 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!";
}
?>


I'm getting following errors



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.


what i wrote wrong in my code?





Aucun commentaire:

Enregistrer un commentaire