SmtpJS -发送嵌入图像的电子邮件



来自https://smtpjs.com/的示例仅展示了如何发送文本和附件。我需要的是嵌入图像作为电子邮件的一部分。

Email.send({
Host : "smtp.yourisp.com",
Username : "username",
Password : "password",
To : 'them@website.com',
From : "you@isp.com",
Subject : "This is the subject",
Body : "And this is the body"
}).then(
message => alert(message)
);

显然正文像HTML脚本一样工作,所以可以通过添加图像路径而不是添加图像作为附件来嵌入STMPJS图像。

表仍然是比使用div的首选。似乎不能让css工作在大多数电子邮件应用。

Email.send({
SecureToken : "***********",
To : emailaddress,
From : "noreply@****.com",
Subject : "Title",
Body : `<div align="center">
<table>
<tr>
<td colspan="3"><img src='imgurl' width="100%"/></td>
</tr>
<tr>
<td width="30%"></td>
<td><a href="link" target="_blank"><img src='imgurl' width="100%" /></a>
</td>
<td width="30%"></td>
</tr>
...
</table>
</div>`,
}).then(
message => console.log("mail sent successfully")
);

最新更新