Ruby on Rails
Action Mailer talks to a sandbox with one smtp_settings block per environment.
Before you start
- Rails 6 or later
1Configure Action Mailer
# config/environments/development.rb config.action_mailer.delivery_method = :smtp config.action_mailer.perform_deliveries = true config.action_mailer.raise_delivery_errors = true config.action_mailer.smtp_settings = { address: 'smtp.mailclutch.com', port: 587, user_name: 'mc_0000000000000000', password: 'pw_0000000000000000', authentication: :plain, enable_starttls_auto: true }
raise_delivery_errors is worth turning on here: without it a refused connection is swallowed and the inbox simply stays empty.
2Send a test message
From rails console:
ActionMailer::Base.mail( from: 'staging@example.com', to: 'anyone@example.com', subject: 'Sandbox check', body: 'Hello from Rails.' ).deliver_now
Watch it land
Open the sandbox and the message is there — rendered HTML, plain text, raw source, attachments, and the SPF, DKIM and DMARC verdicts. It updates live, so you can leave it open next to your terminal.
Nothing is ever delivered onward, whatever address you send to; claim the inbox with an account and it stays.
Awaiting your email
Send from any address; it stops here rather than going onward. The inbox keeps what it catches for 24 hours.
What usually goes wrong
deliver_later needs a worker
deliver_laterhands the mail to Active Job. Either run the queue backend, or usedeliver_nowwhile you are testing.letter_opener and friends
A gem that sets
delivery_methodto:letter_openeror:filein development overrides the block above. Comment it out for the environment you are pointing here.Credentials belong in ENV
The snippet inlines the pair so you can paste it as is. For anything you commit, read it from
ENVor Rails credentials instead.
Other stacks
The same four values in another dialect. Every guide below is filled in with the sandbox pair at the top of this page.
Frameworks and languages
- LaravelFive .env variables, no package
- SymfonyOne MAILER_DSN
- DjangoFive settings, nothing installed
- Node.jsA Nodemailer transport
- Next.jsRoute Handler or Server Action
- Gonet/smtp, standard library
- SpringFive Spring Boot properties
- JavaJakarta Mail, no framework
- .NETMailKit: connect, auth, send
- PHPPHPMailer, no framework
- Pythonsmtplib, standard library
- Rustlettre over a STARTTLS relay