Home > Enterprise >  Laravel 8.x Email Simulation for Testing
Laravel 8.x Email Simulation for Testing

Time:07-20

I want to simulate email send/receive on a Laravel 8.x app, something like using Insomnia or Postman to test REST feature by sending to an endpoint. What I want to do is to send the email to the app, and debug the app processing the email it received, all of them running on a local VM (CentOS 8), without having to send emails using my actual account.

Not much info in the Internet, and results are usually for sending out from Laravel app. Could it be that my scenario is not possible?

CodePudding user response:

if I got your requirements correctly, you could use a mail server like Mailu

  1. run an email server on a docker container
  2. connect your laravel app to the mail server using SFTP
  3. send your email details to your laravel app via HTTP
  4. process your email content or debug it in laravel
  5. send the email to the mail server
  6. or If you received an email in that mailbox, you can get the mails with laravel and process them.

I hope this help.

CodePudding user response:

Not sure if I understand, but you can use Mailhog which is an email-testing tool with a fake SMTP server underneath. MailHog runs a super simple SMTP server that hogs outgoing emails sent to it.

All outgoing emails will be trapped by MailHog, being pretty useful in order to avoid sending emails accidentally when developing.

I've asked (and finally found a solution) in this question: Auto boot MailHog on Ubuntu 20.04 about how to use it in a staging evironment, but running locally with no need to auto start the service is even easier.

There are tons of tutorials about how to implement MailHog and Laravel.

  • Related