Greetings,
The default encoding charset in PHPMailer is ISO-8859-1 (also called Latin-1), and maybe we should reconsider this choice, regarding the fact that UTF-8 is now the web standard. As PHPMailer 6 is still in development, this change should be made before its official released.
As UTF-8 and Latin-1 use the same character table for the ASCII characters, it would be harmless for full English projects to use UTF-8 instead, and an improvement for projects using other languages (I'm currently working on a project using French language and UTF-8, that's why I care ;) ).
If this change is accepted, we have to add something like this in the UPGRADING.md file:
PHPMailer now uses UFT-8 as default encoding charset.
If you want to keep using Latin-1, you should add something like this to your code:
<?php
$phpmailer->CharSet = 'iso-8859-1';
?>
While I think I agree, it's not necessarily an obvious choice. For example, you're using French, for which UTF-8 is entirely unnecessary and is less efficient than ISO-8859-1. In English especially even 8-bit encodings are usually unnecessary, and PHPMailer contains code to automatically fall back to US-ASCII and a 7bit transfer encoding, even if you originally specified UTF-8.
It's actually an RFC contravention to specify an encoding that exceeds what's needed for the message! It's one of the things flagged by the IETF msglint program.
I get that UTF-8 is not the absolute best choice, but I think it's a better choice as a default encoding: ISO-8859-1 is limited to 189 characters, and many applications offer more possibilities to their users (from emoji to different alphabets). Especially if PHPMailer optimises automatically for full ASCII emails as you said, I don't see why ISO-8859-1 should remain as default encoding charset.
There's another issue - the mbstring extension (which PHPMailer requires for UTF-8 support) is not installed by default. It's also not installed by default in any of the default PHP packages on any Ubuntu LTS release of PHP, including PHP 7 on Xenial, nor on Centos and other Red Hat variants, so it must be explicitly installed. That it often is installed isn't really the point - it's not the job of a library to dictate such requirements. We already have some code that checks for the presence of mbstring, but since we don't rely on it by default it needs checking more thoroughly before we can change the default.
In other words, there's a lot more to consider than simply changing the default value. Patches welcome.
Most helpful comment
There's another issue - the
mbstringextension (which PHPMailer requires for UTF-8 support) is not installed by default. It's also not installed by default in any of the default PHP packages on any Ubuntu LTS release of PHP, including PHP 7 on Xenial, nor on Centos and other Red Hat variants, so it must be explicitly installed. That it often is installed isn't really the point - it's not the job of a library to dictate such requirements. We already have some code that checks for the presence of mbstring, but since we don't rely on it by default it needs checking more thoroughly before we can change the default.In other words, there's a lot more to consider than simply changing the default value. Patches welcome.