Last active
December 14, 2015 20:29
-
-
Save AndreaSoto/5144564 to your computer and use it in GitHub Desktop.
Simple email example in RoR and mailgun
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 characters
#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 <[email protected]>", | |
:to => "[email protected]", | |
: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