Created
March 24, 2016 14:56
-
-
Save lukebooth/da278a74926333be50e9 to your computer and use it in GitHub Desktop.
mailgun-ruby Rails setup
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
# in initializers | |
require "ostruct" | |
Rails.configuration.mailgun = OpenStruct.new( | |
YAML.load_file(Rails.root + "config/mailgun.yml")[Rails.env]) |
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
development: | |
api_key: your-private-key | |
mailgun_domain1: your-mailgun1-domain | |
mailgun_domain2: your-mailgun2-domain |
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
message_params = { from: 'bob@sending_domain.com', | |
to: 'sally@example.com', | |
subject: 'The Ruby SDK is awesome!', | |
text: 'It is really easy to send a message!' | |
} | |
client = Mailgun::Client.new(Rails.configuration.mailgun.api_key) | |
client.send_message Rails.configuration.mailgun.mailgun_domain1, message_params |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment