Hi,

On this link:
https://www.php.net/manual/en/function.mail.php

It states:
// To send HTML mail, the Content-type header must be set
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';

Is the charset modern or out of date or old version ?
Should it not be 'utf8mb4' ?

Recommended Answers

All 4 Replies

I’m not near my computer right now to double check, but if memory serves, I use UTF-8 for email and never had an issue.

It would be recommended to use something like utf8 or utf8mb4 if you have a global audience where the email body can contain non-Latin characters.

I wouldn’t say that iso-8859-1 is outdated, per se, but rather that it is only capable of handling Latin characters. Nowadays, it’s much more common to want the flexibility to include emojis in your content, etc. The other thing to consider is most databases use some variant of UTF-8, and you always want to be consistent when pulling data from one place and displaying it somewhere else. I remember a couple of years ago we ran into an issue where our database used one character set, and the database connection was set to a slightly different character set or collation or something like that. (I think one used utf8 and the other used utf8mb4, and it ended up causing some trouble when members had Asian-language usernames).

That was a very long story, typed on my iPhone, to say you should be perfectly safe using utf-8 for your email. Just limit your use of emojis and such because bulk email can get flagged as spam.

I just saw in your profile that you’re in Bangladesh. You will want to use utf-8 for non-English email.

@Dani

Thanks.
But what is the difference between the utf-8 and the utf-8mb4 ?

Utf8mb4 is only used when setting the character set for MySQL databases. It is the equivalent of utf-8, which is the character set you want to use for your html, including email html.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.