如何格式化包含逗号的电子邮件“From”头 [英] How to format an email 'From' header that contains a comma

查看:183
本文介绍了如何格式化包含逗号的电子邮件“From”头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

格式化发件人电子邮件标题的标准方式是

  From:John Doe&john.doe@example .COM> 

但是,如果名字中有逗号,该怎么办?

 来自:John Doe,首席洗瓶机&john.doe@example.com> 

如果我这样做,我的MTA会自动将其转换为:

  From:John@this.server.com,Doe@this.server.com,主洗瓶机&john.doe@example.com> 

我的第一个猜测是在全名中使用双引号,但我找不到任何官方文件证实了这一点,我希望我的电子邮件可以被所有电子邮件客户端读取。

解决方案

要澄清@ Fls'Zen的答案,是的,正确的方法是用双引号括起来。



从实际的角度来说,将所有名称包装在双引号中没有任何危害,只要在显示名称 \(或者只用一个单引号替代)但是如果你想完全符合规格,你不应该使用双引号,如果你不对于所有密集的细节,电子邮件标题字段由 RFC 5322 。From头中的多个发起者的相关部分是 3.6.2 ,引用分隔符的相关部分是 3.2.1 3.2.4


The standard way to format the 'From' email header is

From: John Doe <john.doe@example.com>

But what to do if there's a comma in the name?

From: John Doe, chief bottle washer <john.doe@example.com>

If I do that, my MTA automatically converts this into:

From: John@this.server.com, Doe@this.server.com, chief bottle washer <john.doe@example.com>

My first guess is to use double-quotes around the full name, but I can't find any official documentation confirming this and I'd like my emails to be readable by all email clients.

解决方案

To elaborate on the answer by @Fls'Zen, yes the proper method is to enclose the name in double-quotes.

From a practical point of view there's no harm in wrapping all names in double-quotes, just be sure to escape a double-quote if it appears in the display name \" (or just replace with a single-quote). But if you want to be completely by the spec, you shouldn't use the double quotes if you don't have to.

For all the dense details, E-mail header fields are defined by RFC 5322. The relevant section for multiple originators in the From header is 3.6.2, and the relevant sections for quoting delimiters is 3.2.1 and 3.2.4.

这篇关于如何格式化包含逗号的电子邮件“From”头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆