Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Valid characters in "From:" display name for emails

Tags:

php

email

smtp

I am using PEAR Mail to send emails, and I found that if the "From:" field is something like From: Dragoş <[email protected]>, PEAR returns an error:

Validation failed for: Dragoş <[email protected]>

But, if I remove the ş, PEAR returns true and sends email.

I tried to search on Google and StackOverflow for valid characters, but seems I have no luck here. Does anyone know what are the valid characters for the display name in From field?

Also, is there any way to "encode" these chars to be allowed on this field? I use PHP.

Thank you!
Nuno

like image 227
Nuno Avatar asked Oct 08 '10 13:10

Nuno


People also ask

What is a Display Name email?

The display name is the name that appears on your outgoing emails. This is the name recipients will see when you email them.

Can emails contain symbols?

The short answer is yes, email addresses can include these characters, but with some exceptions. The two biggest factors to consider are hyphen placement and email service provider.


1 Answers

In MIME you have to use only ASCII encoded characters.

In order to pass non-ASCII chars, you have to use Word encoding.

Copied from the linked article:

For example,

Subject: =?iso-8859-1?Q?=A1Hola,_se=F1or!?=

is interpreted as "Subject: ¡Hola, señor!".

The same can be applied to the "name" part (not the email) of the "From" and "To" MIME fields.

like image 124
adamk Avatar answered Nov 27 '22 03:11

adamk