Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

koenverhulst's avatar

Mailer: change to and subject before sending

Hi,

I'm kind a new to laravel.

I'm currently creating a brand new laravel application and I'm trying to implement the following: Depending on the environment (development, test or production) I want to change:

a. The subject of an email (eg: to prefix the current environment) b. Change the to email address to prevent sending emails to real users on an development environment.

I'm using Laravel 5.3.20.

Thanks,

Koen

0 likes
2 replies
oaj's avatar

Are you aware of the log mail driver?

If you modify your .env file on your dev environment and set

MAIL_DRIVER=log

Laravel will now write all mails to the storage/logs/laravel.log file instead of sending the mail for real.

koenverhulst's avatar

Hi oaj,

thanks for your reply.

I'm aware of this feature, but I prefer sending real emails on development and test systems.

Is there a way to modify the to and subject of an email just before sending under certain circumstances (depending on the environment)?

Thanks,

Koen

Please or to participate in this conversation.