The standard way to format the 'From' email header is
From: John Doe <[email protected]>
But what to do if there's a comma in the name?
From: John Doe, chief bottle washer <[email protected]>
If I do that, my MTA automatically converts this into:
From: [email protected], [email protected], chief bottle washer <[email protected]>
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.
A common usage is for defining sub-addresses. Example: The user 'joe' with the mail address '[email protected]' can set up mail addresses like '[email protected]' if he needs more then one address. The comma is used in address header fields to separate email addresses from each other.
In an email, the body (content text) is always preceded by header lines that identify routing information of the message, including the sender, recipient, date and subject. Some headers are mandatory, such as the From, To, and Date headers. Others are optional, but very commonly used, such as Subject and CC.
An email header is the area in which you enter important information above the email content area. The information in the header includes such things as the recipient, the sender, and a subject line with the option of sending copies to additional recipients.
An email header tells who sent the email and where it arrived. Some markers indicate this information, like “From:” — sender's name and email address, “To:” — the recipient's name and email address, and “Date:” — the time and date of when the email was sent. All of these are mandatory indicators.
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.
When the following regular expression matches, then an email display address must be quoted.
[^-A-Za-z0-9!#$%&'*+/=?^_`{|}~\s]
For ASCII characters, this can be done by escaping any double quote characters with a backslash, and enclosing the string in double quotes. For non-ASCII characters, the more complex MIME escaping is required.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With