Hours wasted trying to get AWS SES / PHPMailer to work - anyone done it?

599 views Asked by At

Did all the gyrations to get credentials and configure http on my EC2 instance. Modified my php.ini file to use the same cli sendmail command that works, and...nothing.

Gave up on that and tried installing PHPMailer. Apparently got a little further, but now I get an error message from my code that says:

SMTP -> FROM SERVER:220 email-smtp.amazonaws.com ESMTP
        SimpleEmailService-<chars>
SMTP -> FROM SERVER:250-email-smtp-amazonaws.com 250-8BITMIME
        250-SIZE 10485760 250-STARTTLS 250-AUTH PLAIN LOGIN 250 Ok
SMTP -> FROM SERVER:
SMTP -> ERROR:RSET failed:
SMTP -> NOTICE: EOF caught while checking if connectedThe Following
        From address failed [email protected]:Called Mail() without being
        connected
Mailer Error: The following From address failed: [email protected] : Called
Mail() without being connected

WTF? the address ([email protected]) is an "approved" address. So much for that. Here's the code:

$mail = new PHPMailer();

$mail -> IsSMTP();
$mail -> SMTPAuth = true;
$mail -> SMTPSecure = "tls";
$mail -> Port - 587;
$mail -> Host = "email-smtp.us-east-1.amazonaws.com";
$mail -> Username = "<credentials name>";
$mail -> Password = "<credentials password>";

$mail -> SetFrom('[email protected]', 'User Name');
$mail -> Subject = "email used to be easy - now it's impossible";
$body -> "Drinks are required";
$mail -> MsgHTML($body);
$mail -> AddAddress("[email protected]", "RecipientName");

Pretty simple, wouldn't you think?

...and of course, there is nothing in any log file. It's like sendmail isn't even getting called.

Has anyone gotten this to work - or should we go back to paper?

1

There are 1 answers

1
E.J. Brennan On

May not be your only problem, but I always use port 587, not 567 for SES as you have listed. Give that a try.

Important Amazon Elastic Compute Cloud (Amazon EC2) throttles email traffic over port 25 by default. To avoid timeouts when sending email through the SMTP endpoint from EC2, use a different port (587 or 2587) or fill out a Request to Remove Email Sending Limitations to remove the throttle.

http://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-connect.html