Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Email 在电子邮件中呈现图片';流星中的s模板_Email_Templates_Meteor - Fatal编程技术网

Email 在电子邮件中呈现图片';流星中的s模板

Email 在电子邮件中呈现图片';流星中的s模板,email,templates,meteor,Email,Templates,Meteor,我在/private文件夹中有一个漂亮的电子邮件模板,在/public/images文件夹中有一些图片。我有img标签,带有使用完整路径()或外部链接指向模板的链接。 我使用 SSR.compileTemplate('myTemplate',Assets.getText('myTemplate.html'); renderedTemplate = SSR.render('myTemplate',emailData); var dataContext = { htmlHea

我在/private文件夹中有一个漂亮的电子邮件模板,在/public/images文件夹中有一些图片。我有img标签,带有使用完整路径()或外部链接指向模板的链接。 我使用

SSR.compileTemplate('myTemplate',Assets.getText('myTemplate.html');
renderedTemplate = SSR.render('myTemplate',emailData);
    var dataContext = {
        htmlHead: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">',
        htmlFoot: '</html>'
    };
然后,当我收到我可爱的邮件,一切都很好,完美,但我的附加图像没有加载;这是SSR.compileTemplate的问题吗?通常,静态图片应该附在电子邮件的底部(如果我在gmail中查看“显示原件”),但它们不在那里。。
我做错了什么,应该如何解决?

尝试使用Meteor.absoluteUrl,请参阅文档

可能是这样的:

emailData.absoluteUrl = Meteor.absoluteUrl('/');
然后在模板中:

<img src="{{absoluteUrl}}/path-to-your-image.jpg"/>


我自己还没有试过,所以这是未经测试的。我倾向于直接从S3使用资产。

使用Meteor.absoluteUrl方法是引用图像源的正确方法。但是,我相信即使使用了它,您仍然会面临同样的问题

这是因为您正试图从非公开访问的url引用图像。在您的情况下,
localhost
将是图像完整路径中的主机。html模板需要将图像引用到特定的uri。在这种情况下,它将无法运行,因为它已托管在您的本地计算机上


如果您在托管环境中部署应用程序,将提供您的主机url。希望这有意义。

太好了!让我知道它是如何进行的,如果一切都好,请投票,并按照回答请标记!
<img src="{{absoluteUrl}}/path-to-your-image.jpg"/>