Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set replyTo address for Laravel notifications?

I'm getting

"Call to undefined method Illuminate\Notifications\Messages\MailMessage::replyTo() in ... /TeamMessage.php:68"

I tried to set the replyTo address for notifications like this in TeamMessage.php:

    public function toMail($notifiable)
{
    return (new MailMessage)
        ->replyTo('[email protected]', 'My Name')
        ->line($this->custom_message)
}

I'm guessing it isn't possible to set header info here? Is there another way?I'm using the replyTo() method described at https://laravel.com/api/5.3/Illuminate/Notifications/Messages/MailMessage.html

Edit To add some clarification: I need to be able to set the reply-to address dynamically, so it won't work to hardcode it in a config somewhere.

like image 305
sersun Avatar asked Oct 30 '25 17:10

sersun


1 Answers

The error makes no sense at all. This method is present in MailMessage, the only thing that would make sense is a missing method in your version of the repository. replyTo() is kind of new (nov 2016), so did you

composer update

?

This is the related commit:

https://github.com/laravel/framework/commit/484cfcbdb381e8f36510030b086884e49b898e87

like image 69
Antonio Carlos Ribeiro Avatar answered Nov 01 '25 08:11

Antonio Carlos Ribeiro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!