Last active
January 19, 2019 01:48
-
-
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
This file contains 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 characters
<p>Hello!</p> | |
<div> | |
<%= @message %> | |
</div> | |
<p>-- <%= @fullname %> (<%= @email %>)</p> |
This file contains 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 characters
# ... | |
# 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 | |
} | |
# ... | |
This file contains 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 characters
class UserMailer < ActionMailer::Base | |
default from: '[email protected]' | |
# 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 <[email protected]>', | |
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