This gem provides an easy way to send emails using notifications service.
Add this line to your application's Gemfile:
gem 'amqp_mailer', git: 'https://github.com/GetSimpl/amqp_mailer.git', tag: '<use latest>'
And then execute:
$ bundle
Change action mailer's delivery method to :amqp
config.action_mailer.delivery_method = :amqp
Configure AmqpMailer by setting required parameters
AmqpMailer.configure do |config|
config.amqp_url = ENV['AMQP_URL']
config.notifications_topic_exchange = ENV['NOTIFICATIONS_TOPIC_EXCHANGE']
config.service_id = 'monsters-inc'
end
Pass phone number in addition to other parameters to mail()
method of ActionMailer
mail(to: '[email protected]', subject: 'To Infinity and Beyond', 'X-SIMPL-USER-ID': user_id, 'X-SIMPL-PHONE-NUMBER': phone_number)
To send mail with attachment, upload the file to S3 bucket and send the bucket name and object key in mail attachment attributes as JSON
mail(to: '[email protected]', subject: 'To Infinity and Beyond', 'X-SIMPL-USER-ID': user_id, 'X-SIMPL-PHONE-NUMBER': phone_number, attachments: [{bucket_id: "bucket_name", object_key: "object_key"}].to_json)
This doesn't support multipart emails (yet). That is if you have both <template>.html.erb
and <template>.text.erb
, remove <template>.text.erb
.
After checking out the repo, run bin/setup
to install dependencies. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
.
Some useful resources:
Bug reports and pull requests are welcome on GitHub at https://github.com/GetSimpl/amqp_mailer.
The gem is available as open source under the terms of the MIT License.