Skip to content

Instantly share code, notes, and snippets.

@AndreaSoto
Last active December 14, 2015 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndreaSoto/5144564 to your computer and use it in GitHub Desktop.
Save AndreaSoto/5144564 to your computer and use it in GitHub Desktop.
Simple email example in RoR and mailgun
#email function
#this code below goes on your controller
def sendemail
RestClient.post "https://api:your_api_key_here"\
"@api.mailgun.net/v2/your_app_version_here.mailgun.org/messages",
:from => "Andrea <your@email.com>",
:to => "your@email.com",
:subject => "Title",
:text => "Hello World!"
render :text => "Email Sent"
end
# Configuration
#the code below goes on config->environments->prod or dev.rb
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_charset = "utf-8"
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.smtp_settings = {
:authentication => :plain,
:address => "smtp.mailgun.org",
:port => 587,
:domain => "your_app_version_here.mailgun.org",
:user_name => "username@your_app_version_here.mailgun.org",
:password => "password"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment