如何在出站电子邮件的字段中向 Mailgun 添加逗号?

How to add a comma to a Mailgun from field for outbound emails?

我正在使用 mailgun 推出的 mailgun npm 软件包。

我希望 from 字段在用户电子邮件中显示 "name" 时有一个逗号。

Excited, User <mailgun@sandbox-123.mailgun.org> 但它变成了 User <mailgun@sandbox-123.mailgun.org>

电子邮件中的发件人姓名是 User 而不是 Excited, User

下面是我的代码:(注意 from 字段中的逗号)

mg.messages.create('sandbox-123.mailgun.org', {
    from: "Excited, User <mailgun@sandbox-123.mailgun.org>",
    to: ["test@example.com"],
    subject: "Hello",
    text: "Testing some Mailgun awesomness!"
    html: "<h1>Testing some Mailgun awesomness!</h1>"
  })
  .then(msg => console.log(msg)) // logs response data 
  .catch(err => console.log(err)); // logs any error 

将地址的名称部分用双引号引起来,如下所示:

from: '"Excited, User" <mailgun@sandbox-123.mailgun.org>',

这是我用作参考的网站:http://mailformat.dan.info/headers/from.html

另一种方法是..

'=?UTF-8?q?Excited=2C_User?= <mailgun@sandbox-123.mailgun.org>'

这是我从 Mailgun 收到的答复。

@Freyday - 你的回答非常干净而且工作完美!谢谢:)