Codeigniter SMTP Email with Amazon SES

AFRC picture AFRC · Dec 15, 2011 · Viewed 20.7k times · Source

I think yesterday Amazon announced SMTP support for SES (Simple Email Service).

I tried to send SMTP email with Codeigniter with no luck.

I have a verified sender and everything looks good:

$this->load->library('email');

$config = array(
    'protocol' => 'smtp',
    'smtp_host' => 'email-smtp.us-east-1.amazonaws.com',
    'smtp_user' => 'SMTP USERNAME',
    'smtp_pass' => 'SMTP PASSWORD',
    'smtp_port' => 465,
    'mailtype' => 'html'
);

$this->email->initialize($config);
$this->email->print_debugger();

$this->email->from('[email protected]', 'Test From');
$this->email->to('[email protected]', 'Test To');
$this->email->subject('Test');
$this->email->message('test');

$this->email->send();

I tried the folowing smtp_host:

  • email-smtp.us-east-1.amazonaws.com
  • tls://email-smtp.us-east-1.amazonaws.com
  • ssl://email-smtp.us-east-1.amazonaws.com

When i echo the print_debugger() i get:

220 email-smtp.amazonaws.com ESMTP SimpleEmailService-194655181
hello: 421 Timeout waiting for data from client.

These tests run on a mediatemple (gs) server.

Answer

Stephen picture Stephen · Dec 16, 2011

I got that timeout message until I added the line:-

$this->email->set_newline("\r\n");

I have my host set as ssl://email-smtp.us-east-1.amazonaws.com