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

crisl's avatar
Level 1

Specify the from address in mail failover

I'm currently using the default mailer with transport failover as specified here: https://laravel.com/docs/10.x/mail#failover-configuration

The issue is that to make it working with an external provider i've configurer 2 subdomaines (1 for each mail provider) mail.domain.com & email.domain.com, this is used to make sure i've only one CNAME on the DNS level.

When using the failover, i need to specify the from email address otherwise the external provide is rejecting the mail. [email protected] (first provider) & [email protected] (second provider)

Is there any possibility to detect the mailer used when sending the mail in a notification?

0 likes
5 replies
Snapey's avatar

have you tried putting a from array inside the mailer config used for failover?

crisl's avatar
Level 1

@Snapey I'm not sure to understand what you mean.

The config of the mail failover is in the config/mail.php

'failover' => [
            'transport' => 'failover',
            'mailers' => [
                'smtp',
                'smtp_failover',
            ],
        ],

i understand that you propose to add it in the array of smtp and smtp_failover

My issue is that before sending the notification i need to fetch data from the database and only at that time i could specify the sender (i can't store it in the config files)

Do i miss something?

mankowitz's avatar

I have the same issue. I need to specify a from address for each of the mailers, and also use the default as failover without resorting to the global from address.

When I use Mail::mailer('ses') it works as expected, using the [email protected] email address. However when I use Mail::mailer('failover') or just plain Mail, it uses the global from address.

@snapey - how would you rewrite the failover clause?

Please or to participate in this conversation.