0

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?

Innovit
  • 93
  • 2
  • 13
  • 1
    you need mail trap https://mailtrap.io/ – Jehad Ahmad Jaghoub Jul 20 '22 at 06:23
  • Well I don't see how you would test the flow without actually sending an email. Because this flow also includes testing correct sender and reciever address. So yes, [Mailtrap](https://mailtrap.io/) could help you. – geertjanknapen Jul 20 '22 at 06:41
  • the flow of sending and receiving is not important in this test. It's just to test the message being processed correctly, along with attachment, if any – Innovit Jul 20 '22 at 10:24

2 Answers2

1

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.

1

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.

Luciano
  • 2,052
  • 1
  • 16
  • 26