B
B
BonBon Slick2020-11-29 21:09:15
symfony
BonBon Slick, 2020-11-29 21:09:15

Mailer setup for test/dev/prod envs?

Once upon a time, I configured mailgun for Laravel in such a way that
1 - when env === test, then the email flies to the log file for debugging, naturally rendered
2 - env ​​=== dev, the email flies to the test mailbox of the service that is used (now I'm trying mailgun)
3 - env ​​=== prod the email flies to the user's mailbox or wherever it is indicated using the real data of the sender, the

"symfony/mailer": "^5.1",

mailer's Dock mailer

Example from Fab

But there the mailer is disabled for the test and the dev, but it needs to be tested and verified.

The question is, what configs to register and why exactly?

I'm not sure what will fit as in the example usedsn: '%env(MAILER_DSN)%'after all, phpunit.xml has its own env configs, .env is not used during tests. Therefore, it’s most likely to chordcode the credentials of the test box for dev configs, but it’s not clear how to log an email with all its html into a log file.

Perhaps someone already has configs or an example of how they do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
index0h, 2020-12-03
@BonBonSlick

For unit tests, you don't need to check the delivery itself, that's the mailer's task. Instead, you should check how you call the mailer.
For integration and manual testing, you can deploy a local mail server locally, maildrop for example.
As for testing through the logs - you can of course, but this is not an idea.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question