Reputation: 2419
I need help to figure out how to set the reply-to
field in app/config/mail.php
. I'm using Laravel 4 and it's not working. This is my app/config/mail.php
:
<?php
return array(
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 587,
'from' => [
'address' => '[email protected]',
'name' => 'E-mail 1'
],
'reply-to' => [
'address' => '[email protected]',
'name' => 'E-mail 2'
],
'encryption' => 'tls',
'username' => '[email protected]',
'password' => 'pwd',
'pretend' => false,
);
Upvotes: 41
Views: 55631
Reputation: 3404
Another option is to customizing SwiftMailer Message - https://laravel.com/docs/8.x/mail#customizing-the-swiftmailer-message.
->withSwiftMessage(function ($message) use ($senderEmail) {
$message->getHeaders()
->addTextHeader('Return-Path', $senderEmail);
})
Upvotes: 0
Reputation: 675
I'm using mailable and in my App\Mail\NewUserRegistered::class on the build function I'm doing this,
public function build()
{
return $this->replyTo('email', $name = 'name')
->markdown('emails.admin_suggestion');
}
Upvotes: 0
Reputation: 2339
It's possible since Laravel 5.3 to add a global reply. In your config/mail.php file add the following:
'reply_to' => [
'address' => '[email protected]',
'name' => 'Reply to name',
],
Upvotes: 26
Reputation: 2189
Pretty sure it doesn't work this way. You can set the "From" header in the config file, but everything else is passed during the send:
Mail::send('emails.welcome', $data, function($message)
{
$message->to('[email protected]', 'John Smith')
->replyTo('[email protected]', 'Reply Guy')
->subject('Welcome!');
});
FWIW, the $message
passed to the callback is an instance of Illuminate\Mail\Message
, so there are various methods you can call on it:
Plus, there is a magic __call
method, so you can run any method that you would normally run on the underlying SwiftMailer class.
Upvotes: 103