Skip to content

Instantly share code, notes, and snippets.

@itskingori
Last active January 19, 2019 01:48
Show Gist options
  • Save itskingori/4f72c4b0e6c644bd2bc5 to your computer and use it in GitHub Desktop.
Save itskingori/4f72c4b0e6c644bd2bc5 to your computer and use it in GitHub Desktop.
Getting started quickly with Amazon Email Sending Service (SES) and Ruby on Rails. Test in Rails 4
<p>Hello!</p>
<div>
<%= @message %>
</div>
<p>-- <%= @fullname %> (<%= @email %>)</p>
# ...
# Action Mailer
config.action_mailer.default_options :charset => 'UTF-8'
config.action_mailer.default_url_options = { :host => 'example.com' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = false
config.action_mailer.smtp_settings = { address: 'email-smtp.eu-west-1.amazonaws.com',
port: 587,
domain: 'waabeh.com',
user_name: ENV['SMTP_MAIL_USERNAME'],
password: ENV['SMTPMAIL_PASSWORD'],
authentication: :login,
enable_starttls_auto: true
}
# ...
class UserMailer < ActionMailer::Base
default from: 'noreply@example.com'
# Sends email to the ExampleName from a contact form
def contact_us_email(user)
@email = user[:email]
@fullname = user[:fullname]
@message = user[:message]
mail(cc: "#{@fullname} <#{@email}>",
reply_to: "#{@fullname} <#{@email}>",
to: 'ExampleName <name@example.com>',
subject: user[:subject],
template_path: 'mailer',
template_name: 'contact_us_email')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment