Bojan
Bojan

Reputation: 115

How can I add reply to in Laravel aplication?

I started with the following code:

Mail::to('[email protected]')->send(new ContactFormMail($email_data));

This works fine, but I am not sure how can I add 'reply to' to this code.
Next thing I tried is:

Mail::send('emails.contact-form', $email_data, function ($message) {
  $message->from('[email protected]', 'Laravel');
  $message->to('[email protected]');
  $message->replyTo('[email protected]', 'Laravel');
});

This has the following problem:

No hint path defined for [mail]...

In this case, if I remove @component('mail::message') from the mail view, the message is sent as it should, but it has no styling.
Finally, I do have this piece of code in my Mailable class:

public function build()
{
  return $this->markdown('emails.contact-form');
}

Any assistance would be appreciated.
Thanks

Upvotes: 2

Views: 1606

Answers (1)

Andy Song
Andy Song

Reputation: 4684

The problem you have is that the first argument of Mail::send only accepts either a view email template or a mailable class. however, you passed in a markdown file. so it's not happy with it.

A simple solution is

public function build()
    {
        return $this->markdown('emails.contact-form')
        ->replyTo('[email protected]', 'Laravel');
    }
Mail::to('[email protected]')->send(new ContactFormMail($email_data));

Upvotes: 5

Related Questions