Skip to content

Instantly share code, notes, and snippets.

@lukebooth
Created March 24, 2016 14:56
Show Gist options
  • Save lukebooth/da278a74926333be50e9 to your computer and use it in GitHub Desktop.
Save lukebooth/da278a74926333be50e9 to your computer and use it in GitHub Desktop.
mailgun-ruby Rails setup
# in initializers
require "ostruct"
Rails.configuration.mailgun = OpenStruct.new(
YAML.load_file(Rails.root + "config/mailgun.yml")[Rails.env])
development:
api_key: your-private-key
mailgun_domain1: your-mailgun1-domain
mailgun_domain2: your-mailgun2-domain
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