Search code examples
phpapilaravelmailgun

How to set up headers "h:Reply-To" with Mailgun php API


How to set up headers "Reply-to" in Mailgun php API?

I've using this code but can't imaging hot to set up headers

Mail::send('email.message', $data, function ($message) use ($data) {
            $message->to($data['to_email'], $data['to_name'])
                ->subject($data['subject'])
                ->from($data['from_email'], $data['from_name']);
        });

Solution

  • It's as simple as adding a replyTo on your $message chain

    Mail::send('email.message', $data, function($message) use($data)
    {
        $message->to($data['to_email'], $data['to_name'])
            ->subject($data['subject'])
            ->from($data['from_email'], $data['from_name'])
            ->replyTo('[email protected]');
    });
    

    if you want to add a name to the reply to, just add another parameter with the name:

    ->replyTo('[email protected]', 'Arsen Ibragimov')