0

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)
);
4

1 回答 1

0

显然Body像 html 脚本一样工作,因此可以通过添加图像路径而不是添加图像作为附件来使用 stmpjs 嵌入图像。

与使用 div 相比,table 仍然是首选。似乎无法让 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")
);
于 2021-09-01T17:22:42.670 回答