Отправить письмо с шаблоном блейда с помощью mailgun

Я пытаюсь отправить почту с помощью Mailgun. Если я напишу это:

$mg = Mailgun::create('xxxx');
        $mg->messages()->send('xxxx', [
            'from' => '[email protected]',
            'to' => '[email protected]',
            'subject' => 'Your Link To Login!',
            'text' => 'hello',
        ]);

это работает, но я хочу отправить представление (лезвие), и я не знаю, как это сделать.

Мой код:

public function build(array $customer)
{
  return view('link')->with([
    'customer'=> $customer,
  ]);
}
public function sendContactForm(array $customer)
{
  $aaa=$this->build($customer);
  $mg = Mailgun::create('xxxxxx')

  $mg->messages()->send('xxxx'), [
    'from' => $customer['customerEmail'],
    'to' => '   [email protected]',
    'subject' => 'Contact Message',
    'html' => $aaa,
  ]);
}

Это не работает, когда я пишу html или text.

Что я должен делать?


person d.k    schedule 20.09.2018    source источник
comment
Ну вот... убрал минус.   -  person Sam    schedule 20.09.2018
comment
я просто добавил извините..   -  person d.k    schedule 20.09.2018


Ответы (1)


Добавьте ->render() к вашему вызову сборки, чтобы сохранить содержимое представления в виде строки:

public function build(array $customer)
{
  return view('link')->with([
    'customer'=> $customer,
  ])->render();
}
person aynber    schedule 20.09.2018