【问题标题】:Meteor href in email电子邮件中的流星href
【发布时间】:2020-03-09 19:54:19
【问题描述】:

我正在尝试发送一封正文中带有 href 的电子邮件。

const link= document.createElement("a");
link.href = window.location.href;

emailDetails.body = "Here is an href: \r\n" + link;

Meteor.call("sendEmail", emailDetails.to, email, emailDetails.subject, emailDetails.body);

我的电子邮件方法在哪里

sendEmail: function (to, from, subject, html) {
check([to, from, subject, text], [String]);

this.unblock();

Email.send({
  to: to,
  from: from,
  subject: subject,
  html: html
});

但我没有运气。实际电子邮件消息的来源确实显示了锚标记,但其中没有 href。

我也尝试将 html 放入模板中,然后使用

编译模板
SRR.compileTemplate

并将结果作为我的电子邮件正文传递。但这也行不通。关于如何实现这一点的任何想法?

【问题讨论】:

    标签: javascript html node.js email meteor


    【解决方案1】:

    原来 Gmail 不会呈现锚标记,但 Outlook 会。因此,电子邮件客户端如何处理嵌入的 html 是一个问题。

    【讨论】:

      【解决方案2】:

      其实是可以的,只要使用普通标签即可;而不是document.createElement("a")

      smtp = {
          username: "server@gentlenode.com", 
          password: "3eeP1gtizk5eziohfervU",  
          server: "smtp.gmail.com",
          port: 587
        };
      
        process.env.MAIL_URL =
          "smtp://" +
          encodeURIComponent(smtp.username) +
          ":" +
          encodeURIComponent(smtp.password) +
          "@" +
          encodeURIComponent(smtp.server) +
          ":" +
          smtp.port;
      
        Email.send({
          to: "duckduck@quack.com",
          from: "mew2@gmail.com",
          subject: "hello",
          html: `<p><strong>This will render as bold text</strong>, but this will not.</p> Also, You can direct users to <a href="duckduckgo.com">duckduckgo</a>`
        });
      

      https://themeteorchef.com/tutorials/using-the-email-package

      【讨论】:

      • 普通标签在一个实例中对我不起作用。我可以试试你以后是怎么做的,看看有什么不同
      猜你喜欢
      • 2014-07-30
      • 2016-05-10
      • 2016-11-04
      • 2023-04-05
      • 2019-03-04
      • 1970-01-01
      • 2014-12-19
      • 1970-01-01
      • 2017-12-23
      相关资源
      最近更新 更多