Laravel-邮寄动态主题(使用SparkPost)



我有一个可邮寄的,除了动态设置主题外,我没有任何问题。对于我的一生,我无法将主题行更改为除编程文本(例如 - 您的帐户已经准备就绪),但我想可以说"您的帐户已经准备就绪{{$ user-> name}}}"。

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

"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}}的变量,但是我无法将任何变量传递给我的可邮递主题。

目前,可邮寄的模板:

<?php
namespace AppMail;
use IlluminateBusQueueable;
use IlluminateMailMailable;
use IlluminateQueueSerializesModels;
use IlluminateContractsQueueShouldQueue;
use AppShipment;
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');
    }
}

我正在使用Laravel 5.4。

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}}}}

相关内容

  • 没有找到相关文章

最新更新