Rails mail to a local inbox shared by all your apps
Instead of a Rails letter opener setup, send development email over SMTP to Buggregator: set Action Mailer's smtp_settings to address 127.0.0.1, port 1025. Every email lands in the Buggregator UI, the same inbox your other apps on this machine can use.
Steps
1. Start Buggregator
Run the container. Port 8000 is the web UI, port 1025 is the SMTP server.
docker run --pull always \
-p 127.0.0.1:8000:8000 \
-p 127.0.0.1:1025:1025 \
-p 127.0.0.1:9912:9912 \
-p 127.0.0.1:9913:9913 \
ghcr.io/buggregator/server:latest2. Set the SMTP settings for development
Add this to your development environment file. No username, password or TLS setup is needed.
# config/environments/development.rb
config.action_mailer.smtp_settings = {
address: '127.0.0.1',
port: 1025,
}3. Make sure the delivery method is SMTP
Action Mailer's delivery_method defaults to :smtp. If your development file sets another one, for example :letter_opener or :test, change it in the same file:
config.action_mailer.delivery_method = :smtp4. Send an email and open it
Trigger any mailer, then open http://127.0.0.1:8000. You see the rendered HTML with a desktop/mobile switcher, the plain text version, the addresses, the attachments and the raw MIME source. In Docker Compose, use the Buggregator service name, for example buggregator, instead of 127.0.0.1.
Why it works
Buggregator includes a fake SMTP server that stores each email instead of delivering it. Any app that can send email over SMTP works with it, so a Rails app, a Laravel app and a Node app can all send to the same inbox.
Sources: Rails guides, Action Mailer configuration and config.action_mailer.delivery_method.
Related tips
- Mail
Django emails in a local inbox, not the console
Use Django's SMTP email backend with host 127.0.0.1 and port 1025. Every email lands in Buggregator with HTML, headers and attachments.
- Mail
Nodemailer to a local inbox, no real email sent
Create a Nodemailer SMTP transport for 127.0.0.1:1025 and every message lands in Buggregator with HTML preview and attachments. Nothing is delivered.
- Mail
Laravel mail to a local inbox, three .env lines
Set MAIL_MAILER, MAIL_HOST and MAIL_PORT in .env and every Laravel email lands in Buggregator with HTML preview and attachments. Nothing is delivered.
- Mail
Catch dev email in docker-compose with one service
Add Buggregator as a service in docker-compose.yml and set your app's mail host to its service name. Every email lands in the UI on port 8000.
Checked on with Buggregator v2.8.0