SMTP
Rails SMTP
Configure Action Mailer to deliver through eusend over SMTP — mailers, Devise emails, and any deliver_now/deliver_later, DKIM-signed and tracked.
Action Mailer uses SMTP for delivery, so pointing Ruby on Rails at eusend is a one-block configuration change. Every mailer, plus Devise confirmation and password-reset emails, then routes through eusend, DKIM-signed and tracked.
config/environments/production.rb
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.eusend.dev',
port: 465,
user_name: 'eusend', # the literal string "eusend"
password: ENV['EUSEND_API_KEY'], # eu_live_…
authentication: :plain,
tls: true, # implicit TLS on 465
enable_starttls_auto: false
}
# Must be an address on a domain verified in eusend
config.action_mailer.default_options = { from: 'Acme <no-reply@yourdomain.com>' }⚠
Use tls: true (implicit TLS on port 465), not enable_starttls_auto. On some Ruby/net-smtp
versions the option is ssl: true — both select implicit TLS.
Send an email
class OrderMailer < ApplicationMailer
def shipped(order)
mail(to: order.email, subject: 'Your order has shipped')
end
end
OrderMailer.shipped(order).deliver_now # or deliver_laterTest the connection from the Rails console:
ActionMailer::Base.mail(
from: 'no-reply@yourdomain.com',
to: 'you@example.com',
subject: 'SMTP test',
body: 'Hello from eusend.'
).deliver_nowConnection reference
| Setting | Value |
|---|---|
address | smtp.eusend.dev |
port | 465 |
tls | true |
user_name | eusend |
password | your eusend API key (eu_live_…) |
from | an address on a verified domain |
Use an eu_test_ key in development — sends are tracked but not delivered. See
the SMTP overview for limits and status codes.
Troubleshooting
| Symptom | Cause and fix |
|---|---|
Net::SMTPAuthenticationError (535 …) | Read the response text. Invalid credentials means the username is not the literal eusend or the API key is wrong. A message naming a domain means the From address is on a domain you have not verified. |
Net::ReadTimeout or EOFError: end of file reached when sending | The connection is not using implicit TLS. Set tls: true (or ssl: true on older net-smtp) with port: 465, and keep enable_starttls_auto: false. |
Net::OpenTimeout | Your host blocks outbound port 465, or the port is set to 587 or 25. eusend only accepts SMTP on 465. Ask your host to open it, or send through the HTTP API. |
535 Too many failed attempts or 421 Connection rejected | Repeated failed logins block your IP address for up to an hour. Fix the credentials, then wait before retrying. |
| Nothing arrives and no error is raised | Check config.action_mailer.perform_deliveries is not false and set config.action_mailer.raise_delivery_errors = true so failures surface. Mail sent with deliver_later only goes out while a queue worker is running. |
| Works in production, not in development | smtp_settings above lives in production.rb. Copy it to development.rb, with an eu_test_ key, to send from your machine. |
See the SMTP overview for the full status-code table.