【问题标题】:SmtpJS - Send Email with embed imagesSmtpJS - 发送带有嵌入图像的电子邮件
【发布时间】:2021-10-31 05:12:52
【问题描述】:

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

【问题讨论】:

    标签: javascript email smtp smtpjs


    【解决方案1】:

    显然 Body 像 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")
    );
    

    【讨论】:

      猜你喜欢
      • 2012-04-07
      • 1970-01-01
      • 2015-07-29
      • 2014-01-25
      • 1970-01-01
      • 2011-04-16
      • 2012-12-08
      • 1970-01-01
      相关资源
      最近更新 更多