I added two verified email addresses to AWS SES so that I could send emails from/to them while in the SES Sandbox.
class UserMailer < ApplicationMailer
default from: 'accounts+aws-ses@gofreerange.com'
def welcome_email
mail(to: 'chris.roos@gofreerange.com', subject: 'Welcome to My Awesome Site')
end
end
config.action_mailer.smtp_settings = {
address: 'email-smtp.eu-west-1.amazonaws.com',
port: 25, # or 465 or 587
enable_starttls_auto: <boolean>,
tls: <boolean>,
ssl: <boolean>,
user_name: '<username>',
password: '<password>'
}
$ rails r "UserMailer.with({}).welcome_email.deliver_now"
In summary:
Ports 25 and 587 require enable_starttls_auto to be set to true, and for tls and ssl to be set to false.
Port 465 ignores enable_starttls_auto and requires either tls or ssl to be set to true.
| Port | Enable StartTLS Auto | TLS | SSL | Outcome |
|---|---|---|---|---|
| 25 | True | True | True | OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol |
| 25 | True | True | False | OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol |
| 25 | True | False | True | OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol |
| 25 | True | False | False | Email sent correctly |
| 25 | False | False | False | Net::SMTPAuthenticationError: 530 Must issue a STARTTLS command first |
| 25 | False | True | True | OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol |
| 25 | False | True | False | OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol |
| 25 | False | False | True | OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol |
| 465 | True | True | True | Email sent correctly |
| 465 | True | True | False | Email sent correctly |
| 465 | True | False | True | Email sent correctly |
| 465 | True | False | False | Net::ReadTimeout: Net::ReadTimeout |
| 465 | False | False | False | Net::ReadTimeout: Net::ReadTimeout |
| 465 | False | True | True | Email sent correctly |
| 465 | False | True | False | Email sent correctly |
| 465 | False | False | True | Email sent correctly |
| 587 | True | True | True | OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol |
| 587 | True | True | False | OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol |
| 587 | True | False | True | OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol |
| 587 | True | False | False | Email sent correctly |
| 587 | False | False | False | Net::SMTPAuthenticationError: 530 Must issue a STARTTLS command first |
| 587 | False | True | True | OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol |
| 587 | False | True | False | OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol |
| 587 | False | False | True | OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol |