Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #19083

Re: PHP mail() turns text with special characters into attachments

From Jeroen Belleman <jeroen@nospam.please>
Newsgroups comp.lang.php
Subject Re: PHP mail() turns text with special characters into attachments
Date 2022-09-01 14:24 +0200
Organization Aioe.org NNTP Server
Message-ID <teq89c$g8d$1@gioia.aioe.org> (permalink)
References <teni8h$dar$1@gioia.aioe.org> <630ff4c5$0$690$14726298@news.sunsite.dk>

Show all headers | View raw


On 2022-09-01 01:54, Arne Vajhøj wrote:
> 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.

Thanks for your comments. I think I identified another problem
though. None of the Content-* directives I put in the header at
the sending end remain intact at the receiving end. Small wonder
the mail client doesn't know what to do. Grumble.

The sending end uses xmail rather than sendmail. I wonder if
that may be an issue. I'm beginning to wonder if I'm not better
off moving everything back to the old host.

Never try to fix something that works...

Jeroen Belleman

Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

PHP mail() turns text with special characters into attachments Jeroen Belleman <jeroen@nospam.please> - 2022-08-31 13:56 +0200
  Re: PHP mail() turns text with special characters into attachments Arno Welzel <usenet@arnowelzel.de> - 2022-08-31 14:53 +0200
    Re: PHP mail() turns text with special characters into attachments Jeroen Belleman <jeroen@nospam.please> - 2022-08-31 15:58 +0200
      Re: PHP mail() turns text with special characters into attachments Arno Welzel <usenet@arnowelzel.de> - 2022-09-02 09:22 +0200
  Re: PHP mail() turns text with special characters into attachments Arne Vajhøj <arne@vajhoej.dk> - 2022-08-31 19:54 -0400
    Re: PHP mail() turns text with special characters into attachments Jeroen Belleman <jeroen@nospam.please> - 2022-09-01 14:24 +0200
  Re: PHP mail() turns text with special characters into attachments "He, who travels time to time" <he1983912@aol.com> - 2022-09-22 07:11 -0700

csiph-web