You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This would set the mailer for this mail only to SendGrid even if the mailer in config or env is set to something else.
In that case, the following method returns the wrong mailer, which creates problems.
I expected the mailer to use sendgrid, which was set on the fly, instead of the one set in config or env.
What did you see instead?
The mailer from the config or env was used instead of sendgrid which was set on the fly.
How to Fix
You can always get the current mailer with $this->mailer within the Mailable class. So something like the following may fix the problem without losing the backward compatibility.
/** * @return string */privatefunctionmailDriver()
{
if (!empty($this->mailer)) {
return$this->mailer;
}
if (function_exists('config')) {
returnconfig('mail.default', config('mail.driver'));
}
returnenv('MAIL_MAILER', env('MAIL_DRIVER'));
}
The text was updated successfully, but these errors were encountered:
mukarramkhalid
added a commit
to mukarramkhalid/laravel-sendgrid-driver
that referenced
this issue
Jan 22, 2023
What version of PHP and Laravel are you using?
What did you do?
Starting Laravel version 7, we can change the mailer on the fly. Something like:
This would set the mailer for this mail only to SendGrid even if the mailer in config or env is set to something else.
In that case, the following method returns the wrong mailer, which creates problems.
laravel-sendgrid-driver/src/SendGrid.php
Lines 29 to 35 in b13fec9
What did you expect to see?
I expected the mailer to use
sendgrid
, which was set on the fly, instead of the one set in config or env.What did you see instead?
The mailer from the config or env was used instead of
sendgrid
which was set on the fly.How to Fix
You can always get the current mailer with
$this->mailer
within theMailable
class. So something like the following may fix the problem without losing the backward compatibility.The text was updated successfully, but these errors were encountered: