Most sites send email. Password resets, order confirmations, contact forms, and sign-up notifications all need testing, but you don’t want a local copy of your site emailing real customers, and you don’t want to set up a mail account just to see what a message looks like.
Waddle solves this with MailCatcher, a fake mail server that runs inside your project. Your site sends email exactly as it would on a real server, and MailCatcher catches every message and shows it in your browser instead of delivering it. Nothing ever leaves your machine.
Turn on mail
In the project list, click the paintbrush icon on your project’s row to open the project settings, then the Mail tab. Switch on Enable mail under General.
The tab has three sections:
- General holds the switch, the address your site’s emails come from (From address,
optional), and the internal SMTP port, which you can leave at
1025. - MailCatcher (local) holds the port of MailCatcher’s web page. Leave it at the default.
- SMTP relay (remotes) only matters when you deploy to a server. You can ignore it for now.
Your site always sends its mail to a container called mail on the project’s Docker network.
On your computer, that container is MailCatcher. On a server, the same mail container is an SMTP
relay instead, which passes each message on to the email provider you set up in this section. Your
site’s mail settings never change between the two, only where the mail ends up. See
Mail Architecture for the details.
Click Save, then build the project from the project list. When the build finishes, the envelope icon appears on the project’s row. Clicking it opens MailCatcher in your browser.
Send a test email
Use your site to send something. With WordPress, the quickest way is the Lost your password? link on the login page. Enter the admin username and submit the form.
Your site doesn’t need any mail settings for this. Waddle points PHP’s own mail function
at MailCatcher, so applications that send mail the standard way just work. If your application asks
for an SMTP server instead, use host mail and port 1025, with no username or password.
Read it in MailCatcher
Click the envelope icon on your project’s row. MailCatcher opens in your browser at mail.
followed by your project’s domain, for example https://mail.myblog.localhost.
The top of the page lists every email the project has sent. Click one to read it below, as HTML (when the email has an HTML version), as plain text, or as the raw source with all its headers.
Every message is caught, whatever address it was sent to. You can sign up test users with made-up addresses, place test orders, and submit forms as often as you like.
What happens on a real server
MailCatcher only runs on your computer. When you deploy the project to a server, the same mail service is replaced by a relay that delivers email for real through the provider you set in SMTP relay (remotes). Your application doesn’t notice the difference, because it always sends to the same internal address. Mail Architecture explains how that works.
Next: Debug PHP with Xdebug