yiisoft/yii2-symfonymailer

Can a default sendFrom address be called by updating the configuration file?

developedsoftware opened this issue · 11 comments

At the moment whenever we create a message we have to call setFrom() to set the send from address.

I understand the need for this but could we not have a fallback email - set in the mailer component - to use if setFrom() is not set.

For example a noreply@somedomain email configured at application level

@developedsoftware Do you mean this?

    'class' => \yii\symfonymailer\Mailer::class,
    'messageConfig' => [
        'from' => ['noreply@somedomain' => 'noreply'],
    ],
    'transport' => [],

@developedsoftware talk to me, I miss you :-)

Awesome, thank you.

I will add and close if it works. I assume this means it can be overriden still?

Awesome, thank you.

I will add and close if it works. I assume this means it can be overriden still?

Yes

Hmm, this doesnt appear to make any difference. The message is not configured as per the messageConfig above.

Any ideas?

Screenshot 2022-07-13 at 16 00 34

As you can see it doesnt appear to be configuring the component

@developedsoftware can you show how you configured mailer ?

Sure its this - have replaced the email for obvioius reasons (and made the friendly name the same as the email for the sake of this)

'mailer' => [
            'class' => 'yii\\symfonymailer\\Mailer',
            'messageConfig' => [
                'from' => [
                    'myemail@mydomain.com' => 'myemail@mydomain.com'
                ]
            ],
            'transport' => [
                'dsn' => 'sendmail://default'
            ],
            'useFileTransport' => false
        ]

Are you sure that "class' => 'raptly\symfonymailer\Mailer" is not modified? Is it extends \yii\mail\BaseMailer ?

Sorry thats a class alias. It should be yii.

Would you expect that to work. If so can re-test and post steps to reproduce here? Its almost like messageConfig is being ignored.

Hi @Krakozaber apologies it was a change in an extended class! That works absolutely perfectly. Thank you for your help (and patience)