微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

图片未显示在电子邮件中

如何解决图片未显示在电子邮件中

我有一个字符串形式的 HTML 内容。我想使用电子邮件发送给它。我使用以下代码发送邮件

$email = (new Email())
    ->from(new MimeAddress($sender))
    ->to($recipientEmail)
    ->subject($emailSubject)
    ->html($htmlContent);

$this->mailer->send($email);

$htmlContent 由以下字符串组成:

$wheelsHtml = "";
$logoPath = $this->appKernel->getProjectDir() . '/public/images/logo';

$html .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";
$html .= "
        <html xmlns=\"http://www.w3.org/1999/xhtml\">
        <head>
            <link href=\"https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300;0,400;0,600;0,700;1,300;1,400;1,600;1,700&display=swap\" rel=\"stylesheet\">
            <Meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
            <Meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0\"/>
            <title>Test</title>
        </head>
        <body>
    ";

$html .= "<div style=\"text-align: center; padding-top: 20px; padding-bottom: 20px; font-family: Open Sans;\">
                <img style=\"display: block\" src=\"$logoPath/icon.jpg\">
            </div>";

$html .= "</body></html>";

我在 icon.jpg 中有图像 /public/images/logo。但是在电子邮件不显示此图像。

有人可以帮忙吗?

谢谢。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。