首页 > 解决方案 > 获取徽标以显示在电子邮件标题中

问题描述

我正在使用 Laravel 7 尝试在标题部分发送带有徽标的邮件,但它失败了。我可以将其作为附件发送,并且我在附件列表中看到了图像,但是如何在标题中获取它。

这种方式可以将图像作为附件发送。
return $this->markdown('emails.answered' )->attach($img_url);

这不起作用,或者它可能起作用,但我可以看到图像。
return $this->markdown('emails.answered', ['url_img'=>$img_url]);

这是构建我的可邮寄的构造

    public function __construct($data)
    {
        $this->name   = $data[0]['name'];
        $this->id_no  = $data[0]['id_no'];

        $img_url = env('APP_URL')."img/logo.png";
        $this->logo = $img_url;
    }

在我的刀片中,我尝试过这个。

<img src="{{ $message->embed('img/logo.png') }}">-->未定义变量:消息

和这个。
This is your logo
![Some option text][logo]
[logo]: {{$img_url}} "Logo"

但是没有人想在消息头中获取图像。

这是电子邮件中的图像代码。
<img src="https://ci3.googleusercontent.com/proxy/tUBy2qlV3Ewx803mJ1QPiZ4vxKrPrRAB8qsInc8TGzKEso9Q93o=s0-d-e1-ft#http://img/logo.png" alt="Some option text" title="Logo2" style="font-family:Avenir,Helvetica,sans-serif;box-sizing:border-box;max-width:100%" class="CToWUd">

在此处输入图像描述

标签: laravel

解决方案


在您的电子邮件中,您收到http://img/logo.png"此字符串意味着您的env('APP_URL').此代码不起作用,因此您可以尝试一下

public function __construct($data)
    {
        $this->name   = $data[0]['name'];
        $this->id_no  = $data[0]['id_no'];
        $this->logo = asset('img/logo.png');
    }

然后

This is your logo 
![Some option text][logo]
[logo]: {{ $logo }} "Logo" 

推荐阅读