我有一个图像我转换为base 64编码图像。我正在laravel通过电子邮件发送图像。我尝试将其作为内嵌图像和附件附加。但是作为内嵌图像,图像不会显示,而是在电子邮件页面上显示基本64代码。作为附件,附加图像内部没有任何内容。如果我在laravel的刀片模板视图中渲染,它的效果很好。但是在laravel的电子邮件模板视图中。这是行不通的。为什么??
这是我的代码如下
在控制器中:
$base64 = 'data:image/' . $type . ';base64,' .base64_encode($img_canvas);
IN THE MAILABLE CLASS
Mail::to([$email])->send(new SendPoem($yourname, $mothername, $email, $image));
public function build()
{
return $this->from("[email protected]",'Omo')
->subject("Happy Mother's Day")
->with('yourName', $this->yourName)
->with('motherName', $this->motherName)
->with('motherEmail', $this->motherEmail)
->with('image', $this->image)
->view('emails.send-poem')
->attachData(base64_decode($this->image), 'poem-for-mom.png', [
'mime' => 'image/png',
]);}
在电子邮件视图模板中:
<img class="adapt-img" src="{!! $image !!}"/>
某些电子邮件不支持在电子邮件中发送Base64图像
以下是支持Base64电子邮件的流行电子邮件客户端列表
iOS Mail | Yes
Outlook 2003 | Yes
Apple Mail | Yes
Yahoo! Mail | No
Gmail | No
Android | Yes