I use the PHP mail() function to send emails to a special interest group. Some of these mails are in English, no problems, and some of them are in French. For the latter, the message body text gets turned into an
attachment, and the mail body remains empty. Apparently, it's the
presence of accented characters that triggers this.
The problem appeared when we recently moved the site to a different host. Both the old and the new host are Linux machines, running PHP 5.4.16 and Apache 20120211.
Any ideas as to how to prevent my French text from getting hidden away
in an attachment?
Jeroen Belleman, 2022-08-31 13:56:
I use the PHP mail() function to send emails to a special interest group.
Some of these mails are in English, no problems, and some of them are in
French. For the latter, the message body text gets turned into an
attachment, and the mail body remains empty. Apparently, it's the
presence of accented characters that triggers this.
Why an attachement?[...]
[...]
Please update to at least PHP 7.4 or 8.0 and make sure your code works
with that version (there are some breaking changes in PHP 7/8 compared
to 5):
I use the PHP mail() function to send emails to a special interest group. Some of these mails are in English, no problems, and some of them are in French. For the latter, the message body text gets turned into an
attachment, and the mail body remains empty. Apparently, it's the
presence of accented characters that triggers this.
The problem appeared when we recently moved the site to a different host. Both the old and the new host are Linux machines, running PHP 5.4.16 and Apache 20120211.
Any ideas as to how to prevent my French text from getting hidden away
in an attachment?
On 8/31/2022 7:56 AM, Jeroen Belleman wrote:
I use the PHP mail() function to send emails to a special interest group.
Some of these mails are in English, no problems, and some of them are in
French. For the latter, the message body text gets turned into an
attachment, and the mail body remains empty. Apparently, it's the
presence of accented characters that triggers this.
The problem appeared when we recently moved the site to a different host.
Both the old and the new host are Linux machines, running PHP 5.4.16 and
Apache 20120211.
Any ideas as to how to prevent my French text from getting hidden away
in an attachment?
Non-ASCII should be encoded. Both in headers and body.
function header_encode($str) {
return '=?ISO-8859-1?Q?' . qp_encode($str) . '?=';
}
function body_encode($str) {
return qp_encode($str, true);
}
...
$headers = ... .
"Content-Type: text/plain; charset=ISO-8859-1\r\n" .
... .
"Content-Transfer-Encoding: quoted-printable";
or something similar.
On 2022-08-31 14:53, Arno Welzel wrote:[...]
Please update to at least PHP 7.4 or 8.0 and make sure your code works
with that version (there are some breaking changes in PHP 7/8 compared
to 5):
That's outside my jurisdiction.
I use the PHP mail() function to send emails to a special interest group. Some of these mails are in English, no problems, and some of them are in French. For the latter, the message body text gets turned into an attachment, and the mail body remains empty. Apparently, it's the
presence of accented characters that triggers this.
The problem appeared when we recently moved the site to a different host. Both the old and the new host are Linux machines, running PHP 5.4.16 and Apache 20120211.
Any ideas as to how to prevent my French text from getting hidden away
in an attachment?
Thanks,
Jeroen Belleman
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 349 |
Nodes: | 16 (2 / 14) |
Uptime: | 119:21:18 |
Calls: | 7,612 |
Files: | 12,787 |
Messages: | 5,684,030 |