11 Vote

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

Question by Guest | 2019-03-07 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?

ReplyPositiveNegative
1Best Answer1 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.
2019-03-08 at 17:48

ReplyPositive Negative
Reply

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.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.