Laravel: How to test emails quickly and safely


Your Laravel application will probably have an ability to communicate with your users through emails.

There are many hurdles and challenges when coding an email template for Laravel. The most time-consuming thing is making sure that your email template works well and looks the way you expected it to look like.

Obviously you could register a new Gmail account and create an app with Gmail. That would give you real email delivery that you can check on your phone for example.

The problem here is if you are working with a real database and you can’t afford to send out test emails to your real users. If this is what’s bugging you then I have some good news for you.


As I said, the biggest problem here is that you can’t afford to test on real users. It can become a huge source of frustration for your users and there is only a couple of times when you can do it before they leave your application for good.

My favorite way of testing Laravel email templates is using this service called The way MailTrap works is exactly as it sounds, it intercepts and traps the email on their server, and not letting it go to your end-user.

I think it is important to state that MailTrap is basically a premium tool that you could use for free. The freemium model lets you receive 500 (recently changed from 50) emails maximum. However, you can easily delete these and just keep reusing it over and over.

With this, you get to test your email design and at the same time you can actually see whom it went to, which is something you can’t do with your test Gmail account.

As you know, the starter .env file that you get with Laravel includes variables so you can connect your SMTP server and it looks like this:


What you want to do is head over to and collect the missing information such as username and password.

They will provide this to you from your dashboard page.

Once you enter this data into your .env file, you will need to refresh your config:cache by running php artisan config:cache .

This configuration is tied to Laravel core email delivery meaning that it acts as a system delivery email. So any notification going out from your Laravel application will use this SMTP server to deliver your emails.

What’s good about the paid option is that it gives you an ability to forward that email to a real email address in case you want to check that in your outlook for example.

And this is another tip I want to share. Microsoft Outlook, and I am talking about the desktop application, tends to mess up your email design in case you try to step outside of the plain, regular notification-looking UI. And I have experienced this myself where we basically tested emails by delivering them to Gmail accounts and using the browser to look up emails. However, one of our team members had an outlook that was testing their emails and we saw a drastic change in design.

So MailTrap will help you a lot in case you need to test your email design or simply the whole delivering system and is my go-to service when dealing with emails in the development phase.

About the author