Send

Rails Action Mailer SMTP Setup

Configure Rails Action Mailer with SMTP relay for transactional email, queues, authentication, and delivery webhooks.

Updated

TL;DR

Rails Action Mailer works well with SMTP relay when the From domain is authenticated and mail is delivered through Active Job. Track final delivery state with webhooks rather than assuming Action Mailer delivery means mailbox delivery.

What you will learn

  • Configure Rails SMTP settings
  • Queue transactional mail safely
  • Preserve deliverability during provider migration

Action Mailer SMTP config

Configure production SMTP settings from environment variables:

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  address: "smtp.postscale.io",
  port: 587,
  user_name: ENV.fetch("POSTSCALE_SMTP_USERNAME"),
  password: ENV.fetch("POSTSCALE_SMTP_PASSWORD"),
  authentication: :plain,
  enable_starttls_auto: true
}

Use a verified From domain:

class ApplicationMailer < ActionMailer::Base
  default from: "Acme <alerts@example.com>"
end

Queue mail

Use deliver_later for production transactional mail:

PasswordMailer.reset(user, token_id).deliver_later

Generate and store the token before enqueueing. Queue retries should resend the same token email, not generate a new token each time.

Migration from another provider

  1. Publish Postscale DKIM, SPF, and return-path DNS records.
  2. Keep the old provider's DNS records during transition.
  3. Import bounces, complaints, and unsubscribes.
  4. Change SMTP settings for one environment.
  5. Test password reset, confirmation, and receipt flows.
  6. Add webhook handling for final state.

If you are replacing Postmark, SendGrid, or Mailgun SDK calls, introduce a mail adapter rather than calling provider clients directly from models.

Webhook endpoint

Create a small controller that verifies signatures and stores events by provider event ID. Return 2xx only after durable acceptance.

Use webhook signature verification and webhook retries and idempotency as the implementation baseline.

References

Frequently asked questions

Does Action Mailer delivery mean the email reached the inbox?
No. It means Rails handed the message to the SMTP server or delivery adapter. Use provider webhooks for final state.
Should Rails use port 587 or 465?
Use 587 with STARTTLS unless your deployment requires implicit TLS on 465.

Related guides

Put the guide into production

Postscale brings sending, inbound processing, DMARC reporting, and masked addresses behind one API so the operational pieces stay connected.