Reputation: 67
I am trying to send mail using Amazon SES SMTP with STARTTLS in ExpressionEngine . I am encountering the error below.
I'm unsure why it is complaining it can't send the AUTH LOGIN command before the STARTTLS command - STARTTLS has clearly already been sent. I have tried everything I can think of, and would appreciate it if someone could point me in the right direction.
220 email-smtp.amazonaws.com ESMTP SimpleEmailService-376766033
hello: 250-email-smtp.amazonaws.com
250-8BITMIME
250-SIZE 10485760
250-STARTTLS
250-AUTH PLAIN LOGIN
250 Ok
Failed to send AUTH LOGIN command. Error: 530 Must issue a STARTTLS command first
from: 530 Authentication required
The following SMTP error was encountered: 530 Authentication required
to: 503 Error: need MAIL command
The following SMTP error was encountered: 503 Error: need MAIL command
data: 503 Error: need MAIL command
The following SMTP error was encountered: 503 Error: need MAIL command
500 Error: command not implemented
The following SMTP error was encountered: 500 Error: command not implemented
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
Upvotes: 1
Views: 4614
Reputation: 819
Here's a proper fix.
It is two steps (you can safely ignore the explanations if you want) and does not involve editing any non-config Expression Engine files, so you don't break your upgrade path.
It has been tested it on two Expression Engine installs (each v2.5.3 - Build Date: 20120911) and it's working perfectly.
STEP 1 of 2: Manually edit your {INSTALLDIR}/expressionengine/config/config.php file and add the following three lines at the end:
/* These email configuration variables are required for Amazon SES */
$config['email_smtp_crypto'] = 'tls'; // TLS protocol
$config['email_newline'] = "\r\n"; // SES hangs with just \n
Explanation: The first line sets the default email cryptography to TLS (which SES requires). The second line changes the email newline character from the Expression Engine default of "\n" to the RFC 822 compliant "\r\n" (which SES also requires).
STEP 2 of 2: Via your EE Admin go to "Admin -> Email Configuration" and set the following:
Explanation: Once you have an SES Verified Sender Email Address and You have been granted production access to Amazon SES (both of which need to be done through Amazon's SES Management Console), you can create an AWS account with SMTP credentials via the SES Management Console. In doing this, Amazon SES will give you your own credentials.
For example it should look like this (with wacky usernames and passwords):
To test this via your EE Admin go to "Tools -> Communicate" and send an email.
Upvotes: 4
Reputation: 11
Here's my fix. I haven't had time to figure our why it works but do share if you have the time.
In your EE config file add the following settings (two tls settings as there are multiple examples of either working???):
/* SMTP mail settings
-------------------------------------------------------------------*/
$config['mail_protocol'] = "smtp";
$config['email_smtp_crypto'] = "tls";
$config['smtp_crypto'] = "tls";
$config['smtp_server'] = "AWS-SMTP-ADDRESS";
$config['smtp_username'] = "AWS-SMTP-USERNAME";
$config['smtp_password'] = "AWS-SMTP-PASSWORD";
$config['smtp_port'] = "465";
$config['smtp_timeout'] = 30;
$config['email_crlf'] = "\r\n";
$config['email_newline'] = "\r\n";
Then modify the Codeigniter Email.php class along the lines of this post: http://ellislab.com/forums/viewthread/158882/
The only variation I made was to set $starttls = TRUE by default.
var $starttls = TRUE;
Upvotes: 1