1 1 Vote

PHP Mail: Diacritics and Special Characters in Name and Subject are not displayed

Question by Guest | 07/03/2019 at 18:44

I'm just trying to send an e-mail with PHP's mail function. Everything works so well.

However, only as long as in the header of the mail there are no diacrits, umlauts or other special characters. As soon as I insert characters like Ä, Ö or É into the subject or the sender, they are no longer displayed correctly by my e-mail program.

Can someone tell me what I can do?


Stefan Trost

Show Profile | Message
1Best Answer
1 Vote

Generally, the participating programs and servers only understand ASCII characters in the header of the e-mail. The letters from A to Z fall in this area, the diacrits, umlauts or a wide range of special characters not.

For this reason, you must separately encode the UTF-8 characters within the header:

$text = 'Subject with Ä, Ö and Ü';
$sunject= '=?UTF-8?B?'.base64_encode($text).'?=';

Since this topic is more extensive, I wrote an article about the UTF-8 Header in the PHP-Mail function. In this article you will find an explanation of this line of code as well as a complete example of what a function might look like to prepare and send such a encoded mail.
08/03/2019 at 17:48

ReplyPositive Negative

Related Topics

PHP: Sending an E-Mail
Tutorial | 0 Comments

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.


Ask your own question or write your own articles on askingbox.com. How to do.