In config/mail.php
, we have:
'reply_to' => [
'address' => env('MAIL_REPLY_TO_ADDRESS', 'default@company.com'),
'name' => env('MAIL_REPLY_TO_NAME', 'Company')
],
And the mailable looks like this:
namespace App\Mail;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class SupportMessage extends Mailable implements ShouldQueue
{
use Queueable, SerializesModels;
public $user;
public $senderEmail;
public $message;
public function __construct(User $user, $email, $message)
{
$this->user = $user;
$this->senderEmail = $email;
$this->message = $message;
}
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 default@company.com
, 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 <default@company.com>, sender_email@company.com
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?