GitXplorerGitXplorer
h

multi_smtp

public
8 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
3642b8300791ce82d09350cdd3f49f3631fefbba

Update intro to explain multiple providers

committed 10 years ago
Unverified
676c993ab2ef104b6557a3bf34f0b40fdafb8b8b

Update description to gemspec

committed 10 years ago
Unverified
f5c6d4666a7187f1887cbc116a7dbc66247dab6f

Expand description on error notifications

committed 10 years ago
Unverified
e25ee5752cac1b06f525fcae2d6fd179b21cdf1a

Add instructions on custom notifications

committed 10 years ago
Unverified
c7b055024be1451dd57ae5d32bd6757524211d8d

Bump to version 0.0.2

committed 10 years ago
Unverified
3aea8b3e111d7ae6447a528616e53086c463a4ae

Re-raise the Exception when no notifier is set

committed 10 years ago

README

The README file for this repository.

MultiSMTP

Email delivery is a critical component of many web applications. Occasionally distributed third-party services can experience temporary downtime. We can achieve automatic failover by overriding the default email delivery method with MultiSMTP.

MultiSMTP takes an array of (1..N) SMTP providers and will itterate over each provider untill the email is successfully sent.

Installation

Add this line to your application's Gemfile:

gem "multi_smtp"

And then execute:

$ bundle

Configuration

Set the delivery method to :multi_smtp for each environment that should use the automatic failover.

# config/environments/{staging,production}.rb
ExampleApp::Application.configure do
  config.action_mailer.delivery_method = :multi_smtp
end

In an initializer configure the MultiSMTP class with an array of (1..N) SMTP Providers.

# config/initializers/multi_smtp.rb
sendgrid_settings = {
  address: 'smtp.sendgrid.net',
  authentication: :plain,
  domain: 'example.com',
  password: ENV['SENDGRID_PASSWORD'],
  port: '587',
  user_name: ENV['SENDGRID_USERNAME'],
}

other_smtp_settings = {
  # Other SMTP settings
}

MultiSMTP.smtp_providers = [sendgrid_settings, other_smtp_settings]

Error Notifications

If all SMTP providers fail the default behavior is to re-raise the original exception. However, we can also specify custom notifications.

# config/initializers/multi_smtp.rb
require "multi_smtp/notifiers/airbrake"

MultiSMTP.error_notifier = MultiSMTP::Notifiers::Airbrake

If there is another type of notification you'd like to receive, you can create a new notifier that implements the class method .notify.

class MyCustomNotifier
  def self.notify(mail)
    # do something special
  end
end

MultiSMTP.error_notifier = MyCustomNotifier

See the Airbrake Notifier for more details.

Contributing

  1. Fork it ( https://github.com/[my-github-username]/multi_smtp/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request