DEV Community

KILLALLSKYWALKER
KILLALLSKYWALKER

Posted on

The Staging Strikes Back: Safer Emails in Laravel with Mailpit

When building a job portal , there's so much email transaction that will be send to user . As an example like candidate receive the job status , company view the profile , company receive notification when applicant apply and so many more .

So we need to ensure the test including the email send when it been test . By right , when we have small feature , small flow to test , the QA just use and create their own dummy email , but when the test has to much , QA also run out of email . But it's not only about this , what happen if QA use wrong email which is actually belong to real user outside , wrong recipient and send the email ?

Why not using log ? It easy for developer but not QA . How about mailtrap ? Mailtrap great , its work , but had cost and we dont want our data go outside .

Mailpit , A New Hope

Mailpit is an open-source SMTP server + web UI that catches all emails sent from our Laravel app. Instead of leaving your staging environment, every email lands in Mailpit’s inbox at http://localhost:8025 or any port you set ( in our case we using our domain ) . Of course our staging environment is protected .

You can setup it and refer to its documentation Mailpit

Closing

After we use mailpit , we make the QA life easier , no more worry about test email reaching unintended user . On top of that we also can preview the email in different mode in one place .

Sorry for no code example for this , maybe later i can create a simple tutorial for this :)

Top comments (0)