uSend Docs
SMTP guides

Rails

Point Action Mailer at usend over SMTP.

Action Mailer needs only configuration. Settings used on this page: host smtp.usend.et, port 587 or 465, username usend, password your API key. Reference: Send with SMTP.

Configure

config/environments/production.rb
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { host: 'app.acme.com', protocol: 'https' }

config.action_mailer.smtp_settings = {
  address: 'smtp.usend.et',
  port: 587,
  user_name: 'usend',
  password: Rails.application.credentials.dig(:usend, :api_key), # or ENV.fetch('USEND_API_KEY')
  authentication: :plain,
  enable_starttls_auto: true,
  open_timeout: 10,
  read_timeout: 30,
}

For implicit TLS use port: 465 and ssl: true (and drop enable_starttls_auto).

Set a default sender

app/mailers/application_mailer.rb
class ApplicationMailer < ActionMailer::Base
  default from: 'Acme <[email protected]>'
  layout 'mailer'
end

The address must be on a verified domain. A mailer then works as always:

ruby
UserMailer.welcome(user).deliver_later

Use deliver_later so Active Job sends the mail and retries failures.

Test it

Shell
bin/rails runner 'ActionMailer::Base.mail(from: "[email protected]", to: "[email protected]", subject: "Test", body: "It works").deliver_now'

Troubleshooting

  • Net::SMTPAuthenticationError 535: the password is not a valid key. Credentials set for another environment are the usual cause.
  • Net::SMTPFatalError 554: read the message; it is the same text the API returns (unverified domain, suspended or sandboxed organization).
  • Net::SMTPServerBusy 421/451/452: temporary. Active Job retries it; configure retry_on Net::SMTPServerBusy.

API alternative with the email id and scheduling: Send with Rails.