In config/mail.php
we have:
'reply_to' => [
'address' => env('MAIL_REPLY_TO_ADDRESS', '[email protected]'),
'name' => env('MAIL_REPLY_TO_NAME', 'Company')
],
And the mailable looks like this:
<?php
namespace AppMail;
use AppUser;
use IlluminateBusQueueable;
use IlluminateContractsQueueShouldQueue;
use IlluminateMailMailable;
use IlluminateQueueSerializesModels;
class SupportMessage extends Mailable implements ShouldQueue
{
use Queueable, SerializesModels;
public $user;
public $senderEmail;
public $message;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct(User $user, $email, $message)
{
$this->user = $user;
$this->senderEmail = $email;
$this->message = $message;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->markdown('emails.support-message')
->subject('Support Message')
->replyTo(['email' => $this->senderEmail]);
}
}
For some reason instead of replacing the default reply-to
header in the email Laravel concatenates $this->senderEmail
onto the existing [email protected]
which email clients don’t seem to be responding to (blank email list when replying). The header comes through looking something like this: reply-to: Company <[email protected]>, [email protected]
I have also tried ->replyTo($this->senderEmail)
which results in the same concatenation.
Is there a way to replace the global reply-to
rather than concatenating?
2
Answers
I would try to override function setAddress() in your mailable class, or if i’d have multiple emails, then create new class which extends mailable and in concerned email extend this new class.
Something like this :
Try to add a new
Reply-To
header using theaddTextHeader()
method.