email - 从 Go 发送带有 "Name"<email> 的电子邮件

标签 email go smtp standard-library

我正在使用 net/smtp 发送电子邮件,它似乎无法处理电子邮件中的联系人姓名。

c, _ := smtp.Dial("smtp.example.com:25")
c.Mail(`jdoe@example.com`)

而不是

c, _ := smtp.Dial("smtp.example.com:25")
c.Mail(`"John Q. Doe" <jdoe@example.com>`)

有没有什么好的方法来处理这个问题?如果可用的话,我更喜欢封装和标准的东西,但如果可以做到的话,我愿意使用原始 SMTP。

最佳答案

你能试试不用双引号吗?即

c.Mail(`John Q. Doe <jdoe@example.com>`)

关于email - 从 Go 发送带有 "Name"<email> 的电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36485857/

相关文章:

google-app-engine - 无效的应用程序配置错误: Duplicate module: my-service

ruby-on-rails - 在 Rails 中发送电子邮件

email - 如何在 Jenkins 中设置发件人地址?

php - 无法在 ubuntu/linux 中使用 PHPmailer 和 smtp 发送

PHPMailer 在我使用 nginx 的 Digital Ocean 服务器上导致 504 超时错误

go - 使用 rows.NextResultSet() 在多结果集查询中调用 rows.Err()

Python O365 使用 HTML 文件发送电子邮件

pointers - 递归地附加到 slice

javascript - 如何从“通知我”字段中获取电子邮件

ios - iOS swift 触发后台邮件