“Reply-to” field in Laravel mail is not working

前端 未结 3 1333
陌清茗
陌清茗 2020-12-09 15:34

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/co

相关标签:
3条回答
  • 2020-12-09 16:02

    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');
        }
    
    0 讨论(0)
  • 2020-12-09 16:04

    It's possible since Laravel 5.3 to add a global reply. In your config/mail.php file add the following:

    'reply_to' => [
        'address' => 'info@xxxxx.com',
        'name' => 'Reply to name',
    ],
    
    0 讨论(0)
  • 2020-12-09 16:09

    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('foo@example.com', 'John Smith')
            ->replyTo('reply@example.com', '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:

    • ->from($address, $name = null)
    • ->sender($address, $name = null)
    • ->returnPath($address)
    • ->to($address, $name = null)
    • ->cc($address, $name = null)
    • ->bcc($address, $name = null)
    • ->replyTo($address, $name = null)
    • ->subject($subject)
    • ->priority($level)
    • ->attach($file, array $options = array())
    • ->attachData($data, $name, array $options = array())
    • ->embed($file)
    • ->embedData($data, $name, $contentType = null)

    Plus, there is a magic __call method, so you can run any method that you would normally run on the underlying SwiftMailer class.

    0 讨论(0)
提交回复
热议问题