Ruby on Rails
Action Mailer talks to a sandbox with one smtp_settings block per environment.
Prerequisites
- 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 sandbox 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 sandbox with an account and it stays.
Awaiting your email
Send from any address; it stops here rather than going onward. The sandbox keeps what it catches for 24 hours.
Go further
deliver_later and Active Job
deliver_laterhands the mail to Active Job. Either run the queue backend, or usedeliver_nowwhile you are testing.letter_opener and :file delivery
A gem that sets
delivery_methodto:letter_openeror:filein development overrides the block above. Comment it out for the environment you are pointing here.
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