views:

18

answers:

2

Hey,

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

+2  A: 

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.

adamk
Thank you! That worked well! I thought I could only use this for Subject. I have just tested on From and worked well so far :)
Nuno Peralta
I don't see the linked Wikipedia article? --> http://en.wikipedia.org/wiki/MIME
moontear
A: 

When in doubt, consult the standard. What you're after is the display-name token, which is described on page 14.

Blrfl