【发布时间】:2018-05-12 17:02:20
【问题描述】:
以下代码运行良好:
Mail::send([], [], function ($message) {
$message->to('example@gmail.com')
->subject('Test Subject')
->setBody('<h1>Hi, welcome user!</h1>', 'text/html');
});
// check for failures
echo Mail::failures() ? 'Failed to send' : 'Sent';
但是,当我将图像标签添加到电子邮件正文时,如下所示:
Mail::send([], [], function ($message) {
$message->to('example@gmail.com')
->subject('Test Subject')
->setBody('<h1>Hi, welcome user!</h1> <img src="http://absolute_path_to_image">', 'text/html');
});
// check for failures
echo Mail::failures() ? 'Failed to send' : 'Sent';
sn-p 返回“Sent”,没有任何错误信息。我检查了日志文件,但一无所获。日志文件中没有任何信息。
应用程序位于启用 SSL 密钥的子域下,例如 https://secure.example.com。
请注意,该应用曾在同一台服务器上运行,但在不同的子域下运行,例如 https://secure.olddomain.com。我不确定它是否与此有关。
如果您之前遇到过此问题,请帮助并分享您的解决方案。
谢谢, 网络
【问题讨论】:
-
你要发送附件扔你的邮件吗?
-
不,我不知道。只是一封带有图片的简单 HTML 电子邮件
-
这个对我有用:图像在电子邮件视图中声明如下:
<img src="{{ $message->embed(public_path() . '/x/x.png') }}" alt="" />希望这对你有帮助! -
@SAPNET 你检查过我下面的答案了吗?在我把我的 cmets 放在这里之后,我已经发布了它。
-
@Hiren Gohel:您的解决方案也有效。非常感谢您的参与。 Rimon 的回答在提到图像的绝对路径时更准确。
标签: php laravel email laravel-4