【问题标题】:nodemailer - anchor tag not workingnodemailer - 锚标签不起作用
【发布时间】:2016-03-15 08:53:41
【问题描述】:

每当我尝试使用 nodemailer v1.10 发送带有锚标记的电子邮件时,我的电子邮件中都会混杂一个 3D 字符。我相信这是%3D,解码时代表=。我使用 gmail 作为 SMTP 传输服务。

这是我在 nodemailer 中使用的“html”值

var resetUrl = req.protocol + '://' + req.get('host') + ':' + req.app.get('port') + '/password/reset?token=' + encodeURIComponent(digest);
options.html = 'To reset your password, click this <a href="' + resetUrl + '"><span>link</span></a>.<br>This is a <b>test</b> email.'

这是我在收到的电子邮件中点击“显示原件”时的样子。

To reset your password, click this <a href=3D"http://192.168.1.=
109:3000:3000/password/reset?token=3DoU5J1vm4VTLl0Ru8SMI7x3YvF3Y%3D"><span>=
link</span></a>.<br>This is a <b>test</b> email.

我还注意到每行末尾都有=。这对gmail来说正常吗?我收到的电子邮件在 gmail 中确实显示正常。该链接具有蓝色字体颜色并带有下划线,但当我单击它时它不起作用。我也在雅虎邮箱里试过了,链接也失效了。

【问题讨论】:

    标签: javascript node.js email gmail nodemailer


    【解决方案1】:

    我通过将锚标记中使用的引号从 " 更改为 ' 来修复它

    之前:

    options.html = 'To reset your password, click this <a href="' + resetUrl + '"><span>link</span></a>.<br>This is a <b>test</b> email.'
    

    之后:

    options.html = "To reset your password, click this <a href='" + resetUrl + "'><span>link</span></a>.<br>This is a <b>test</b> email."
    

    【讨论】:

    • 我发现在单引号内加上双引号总是更好,而不是相反。
    猜你喜欢
    • 2016-05-14
    • 2011-08-03
    • 2010-11-10
    • 1970-01-01
    • 1970-01-01
    • 2021-09-29
    • 2017-12-06
    相关资源
    最近更新 更多