【问题标题】:Send blade template mail with mailgun使用 mailgun 发送刀片模板邮件
【发布时间】:2018-09-20 13:04:52
【问题描述】:

我正在尝试使用 Mailgun 发送邮件。如果我这样写:

$mg = Mailgun::create('xxxx');
        $mg->messages()->send('xxxx', [
            'from' => 'dmt.akyol@gmail.com',
            'to' => 'dmt.akyol@gmail.com',
            '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' => '   dmt.akyol@gmail.com',
    'subject' => 'Contact Message',
    'html' => $aaa,
  ]);
}

当我写 htmltext 时,这不起作用。

我该怎么办?

【问题讨论】:

  • 你去...删除了downvote。
  • 我刚刚补充了抱歉..

标签: php laravel laravel-blade mailgun laravel-mail


【解决方案1】:

->render() 添加到您的构建调用中以将视图的内容存储为字符串:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-09-28
    • 2019-05-27
    • 2015-10-10
    • 2017-10-12
    • 2015-03-29
    • 2016-01-24
    • 2014-04-14
    • 2015-03-25
    相关资源
    最近更新 更多