首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >动态主题(使用SparkPost)

动态主题(使用SparkPost)
EN

Stack Overflow用户
提问于 2017-12-19 04:19:27
回答 1查看 880关注 0票数 1

我有一个邮件,我没有任何真正的问题,除了动态设置的主题。在我的生活中,我不能将主题行更改为编程文本(例如,您的帐户已准备好),但我希望能够说“您的帐户已准备好{$user->name}”。

但是,当我这样做时,将返回以下错误:

代码语言:javascript
复制
"message": "Client error: `POST https://api.sparkpost.com/api/v1/transmissions` resulted in a `422 Unprocessable Entity` response:\n{ \"errors\": [ { \"message\": \"substitution language syntax error in template content\", \"description\": \"Error while compili (truncated...)\n",
    "exception": "GuzzleHttp\\Exception\\ClientException",
    "file": "C:\\xampp\\htdocs\\truckin\\vendor\\guzzlehttp\\guzzle\\src\\Exception\\RequestException.php",
    "line": 113,
    "trace": [

我可以在电子邮件正文中传递{{$user->name}之类的变量,但不能将任何变量传递给我的可邮件主题。

目前,mailable有以下模板:

代码语言:javascript
复制
<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

use App\Shipment;

class newFreightBill extends Mailable
{
    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public $shipment;

    public function __construct(Shipment $shipment)
    {
        $this->shipment = $shipment;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->from('myEmail@email.com')
                    ->subject('New Account Created')
                    ->view('emails.account.created');
    }
}

我用的是Laravel5.4。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-12-19 04:35:21

代码语言:javascript
复制
public function build()
    {
        $data['name']     = 'pass your user name here';
        return $this->from('myEmail@email.com')
                    ->subject('New Account Created')
                    ->view('emails.account.created',$data);
    }
  1. 在视图页面(emails.account.created)中,您可以这样调用“您的帐户准备好了{{$user->name}”
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47879971

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档