Last active
January 25, 2022 20:24
-
-
Save chrisroos/6b32b07aefa010526f7e5cfe58d61978 to your computer and use it in GitHub Desktop.
Revisions
-
chrisroos revised this gist
Apr 30, 2018 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -40,9 +40,11 @@ Ports 25 and 587 require `enable_starttls_auto` to be set to `true`, and for `tl Port 465 ignores `enable_starttls_auto` and requires either `tls` or `ssl` to be set to `true`. This relates to the [Connecting to the Amazon SES SMTP Endpoint documentation](https://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-connect.html) which says that SES supports STARTTLS on ports 25, 587 and 2587, and supports TLS on ports 465 and 2465. ## Results | 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` | -
chrisroos revised this gist
Apr 30, 2018 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -34,14 +34,14 @@ config.action_mailer.smtp_settings = { $ rails r "UserMailer.with({}).welcome_email.deliver_now" ``` ## Result 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`. ## Results | 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` | -
chrisroos revised this gist
Apr 30, 2018 . 1 changed file with 16 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -44,27 +44,27 @@ Port 465 ignores `enable_starttls_auto` and requires either `tls` or `ssl` to be | 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` | -
chrisroos revised this gist
Apr 30, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -43,6 +43,7 @@ Ports 25 and 587 require `enable_starttls_auto` to be set to `true`, and for `tl 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 | -
chrisroos revised this gist
Apr 30, 2018 . 1 changed file with 39 additions and 85 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,6 @@ # Testing Rails ActionMailer and AWS SES I added two verified email addresses to AWS SES so that I could send emails from/to them while in the SES Sandbox. # UserMailer @@ -12,104 +14,56 @@ class UserMailer < ApplicationMailer end ``` # ActionMailer config ``` 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>' } ``` ## Test command ``` $ rails r "UserMailer.with({}).welcome_email.deliver_now" ``` ## Results 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 | -
chrisroos revised this gist
Apr 30, 2018 . 1 changed file with 24 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -89,3 +89,27 @@ config.action_mailer.smtp_settings = { password: '<password>' } ``` ``` $ rails c > UserMailer.with({}).welcome_email.deliver_now # No errors and the email is sent correctly. ``` # Using none of 'Enable Start TLS Auto', 'SSL' or 'TLS' ``` config.action_mailer.smtp_settings = { address: 'email-smtp.eu-west-1.amazonaws.com', port: 25, enable_starttls_auto: false, user_name: '<username>', password: '<password>' } ``` ``` $ rails c > UserMailer.with({}).welcome_email.deliver_now Net::SMTPAuthenticationError: 530 Must issue a STARTTLS command first ``` -
chrisroos created this gist
Apr 30, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,91 @@ I added two verified email addresses to SES so that I could send emails from/to them while in the SES Sandbox. # UserMailer ``` 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 ``` # Using ActionMailer config from CoTech Cobudget ('Enable Start TLS Auto', 'SSL' and 'TLS') This results in an SSL error. ``` config.action_mailer.smtp_settings = { address: 'email-smtp.eu-west-1.amazonaws.com', port: 25, enable_starttls_auto: true, tls: true, ssl: true, user_name: '<username>', password: '<password>' } ``` ``` $ rails c > UserMailer.with({}).welcome_email.deliver_now OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol ``` # Using 'Enable Start TLS Auto' and 'TLS' This results in an SSL error. ``` config.action_mailer.smtp_settings = { address: 'email-smtp.eu-west-1.amazonaws.com', port: 25, enable_starttls_auto: true, tls: true, user_name: '<username>', password: '<password>' } ``` ``` $ rails c > UserMailer.with({}).welcome_email.deliver_now > OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol ``` # Using 'Enable Start TLS Auto' and 'SSL' This results in an SSL error. ``` config.action_mailer.smtp_settings = { address: 'email-smtp.eu-west-1.amazonaws.com', port: 25, enable_starttls_auto: true, ssl: true, user_name: '<username>', password: '<password>' } ``` ``` $ rails c > UserMailer.with({}).welcome_email.deliver_now > OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol ``` # Using 'Enable Start TLS Auto' This works correctly. And presumably encrypts the traffic. ``` config.action_mailer.smtp_settings = { address: 'email-smtp.eu-west-1.amazonaws.com', port: 25, enable_starttls_auto: true, user_name: '<username>', password: '<password>' } ```