[英]Laravel email shows images fine in Mailtrap but not visible in Gmail
I am using a simple Laravel Mailable below and have the header image displayed at the top of the email - this displays fine when going through Mailtrap.io but when the same email is sent to my Gmail account in the live environment it doesn't display - 我究竟做錯了什么?
class TwoFactorMail extends Mailable
{
use Queueable, SerializesModels;
public $code;
public function __construct($code)
{
$this->code = $code;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->markdown('emails.twofactor');
}
}
刀片文件
@component('mail::message')
<html>
<head>
<title>Two Factor</title>
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Poppins|Roboto&display=swap" rel="stylesheet">
</head>
<body>
<img src="data:image/png;base64,{{base64_encode(file_get_contents(resource_path('img/header.jpg')))}}" alt="">
<h1 class="header padded-margin">Authentication code</h1><hr class="divider">
<p>Your Two-Factor Authentication is below. Add the code into your browser to complete your CrowdControlHQ Sign In.</p>
<div class="code padded-margin">{{ $code }}</div>
<p>If you didn’t request this code there is nothing to worry about - you can safely ignore it.</p>
</body>
</html>
@endcomponent
最好使用基於標准 url 的 src 作為您的圖像標簽。
只需確保在 url 中包含域名,如下所示。
<img src="http://www.example.com/image.jpg" alt="img" />
大多數現代 email 客戶端不接受 base64 圖像。
你可以在這里讀更多關於它的內容
https://blog.mailtrap.io/embedding-images-in-html-email-have-the-rules-changed/
搜索頁面並閱讀這兩個主題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.