Skip to content

Instantly share code, notes, and snippets.

@albertico
Last active November 6, 2018 06:46
Show Gist options
  • Save albertico/2644a0c6e3ee70e64fe66f9bee58bab7 to your computer and use it in GitHub Desktop.
Save albertico/2644a0c6e3ee70e64fe66f9bee58bab7 to your computer and use it in GitHub Desktop.
SMTP Examples for Amazon SES and WorkMail
#!/usr/bin/env ruby
require 'mail'
Mail.defaults do
delivery_method :smtp, { :address => "email-smtp.us-east-1.amazonaws.com",
:port => 587,
:user_name => "YOUR_IAM_SMTP_USER_FOR_SES",
:password => "YOUR_VERY_LONG_PASSWORD",
:authentication => 'plain',
:enable_starttls_auto => true }
end
mail = Mail.deliver do
from 'from@your-validated-ses-identity.domain'
to 'to@recipient.domain'
subject 'Hello from Amazon SES'
text_part do
body "This message has been sent through Amazon SES."
end
html_part do
content_type 'text/html; charset=UTF-8'
body "<p>This message has been sent through Amazon <strong>SES</strong>.</p>"
end
end
#!/usr/bin/env ruby
require 'mail'
Mail.defaults do
delivery_method :smtp, { :address => "smtp.mail.us-east-1.awsapps.com",
:port => 465,
:user_name => "your@amazon-workmail-user-account.email",
:password => "YOUR_VERY_LONG_PASSWORD",
:authentication => 'login',
:ssl => true,
:enable_starttls_auto => false }
end
mail = Mail.deliver do
from 'your@amazon-workmail-user-account.email'
to 'to@recipient.domain'
subject 'Hello from Amazon WorkMail'
text_part do
body "This message has been sent through Amazon WorkMail."
end
html_part do
content_type 'text/html; charset=UTF-8'
body "<p>This message has been sent through Amazon <strong>WorkMail</strong>.</p>"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment