Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

It is easier to change the specification to fit the program than vice versa.


devel / comp.lang.php / Re: PHP mail() turns text with special characters into attachments

SubjectAuthor
* PHP mail() turns text with special characters into attachmentsJeroen Belleman
+* Re: PHP mail() turns text with special characters into attachmentsArno Welzel
|`* Re: PHP mail() turns text with special characters into attachmentsJeroen Belleman
| `- Re: PHP mail() turns text with special characters into attachmentsArno Welzel
+* Re: PHP mail() turns text with special characters into attachmentsArne Vajhøj
|`- Re: PHP mail() turns text with special characters into attachmentsJeroen Belleman
`- Re: PHP mail() turns text with special characters into attachmentsHe, who travels time to time

1
PHP mail() turns text with special characters into attachments

<teni8h$dar$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=649&group=comp.lang.php#649

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!aioe.org!ICt92rkpUtdiBkqMoKbPBQ.user.46.165.242.91.POSTED!not-for-mail
From: jeroen@nospam.please (Jeroen Belleman)
Newsgroups: comp.lang.php
Subject: PHP mail() turns text with special characters into attachments
Date: Wed, 31 Aug 2022 13:56:03 +0200
Organization: Aioe.org NNTP Server
Message-ID: <teni8h$dar$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="13659"; posting-host="ICt92rkpUtdiBkqMoKbPBQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0
X-Notice: Filtered by postfilter v. 0.9.2
 by: Jeroen Belleman - Wed, 31 Aug 2022 11:56 UTC

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

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

<jn93uiFpvo0U1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=650&group=comp.lang.php#650

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: usenet@arnowelzel.de (Arno Welzel)
Newsgroups: comp.lang.php
Subject: Re: PHP mail() turns text with special characters into attachments
Date: Wed, 31 Aug 2022 14:53:38 +0200
Lines: 51
Message-ID: <jn93uiFpvo0U1@mid.individual.net>
References: <teni8h$dar$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Trace: individual.net WwPvjyahLncoBzoMlMmO4gmqQTOAnurI4+IKtPEh23ByHtTIUs
Cancel-Lock: sha1:kQTt/KhkUCAr9jndqyzoQJlfUVw=
Content-Language: de-DE
In-Reply-To: <teni8h$dar$1@gioia.aioe.org>
 by: Arno Welzel - Wed, 31 Aug 2022 12:53 UTC

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? Why not just adding the appropriate MIME headers
about the encoding and sending the text as UTF-8 or ISO-8859-1 or to be
safe using quoted-printable for the transport?

Also see:

<https://www.php.net/manual/en/function.quoted-printable-encode.php>

> 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.

The first release of PHP 5.4 is more than 10(!) years old that version
is *way* outdated!

You should not use that version at all. Before doing any problem
analysis you should first upgrade your environment. Besides possible
security problems also bugs may be present which got fixed in newer version.

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):

<https://www.php.net/supported-versions.php>

> Any ideas as to how to prevent my French text from getting hidden away
> in an attachment?

As suggested above - do not use attachements but just add the text with
an appropriate encoding. There is no need to use attachments just
because you use 8-bit characters.

You can also use PHPMailer to make this process easier (which of course
also requires a decent PHP version):

<https://github.com/PHPMailer/PHPMailer>

--
Arno Welzel
https://arnowelzel.de

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

<tenper$1p5o$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=651&group=comp.lang.php#651

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!aioe.org!ICt92rkpUtdiBkqMoKbPBQ.user.46.165.242.91.POSTED!not-for-mail
From: jeroen@nospam.please (Jeroen Belleman)
Newsgroups: comp.lang.php
Subject: Re: PHP mail() turns text with special characters into attachments
Date: Wed, 31 Aug 2022 15:58:54 +0200
Organization: Aioe.org NNTP Server
Message-ID: <tenper$1p5o$1@gioia.aioe.org>
References: <teni8h$dar$1@gioia.aioe.org> <jn93uiFpvo0U1@mid.individual.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="58552"; posting-host="ICt92rkpUtdiBkqMoKbPBQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0
X-Notice: Filtered by postfilter v. 0.9.2
 by: Jeroen Belleman - Wed, 31 Aug 2022 13:58 UTC

On 2022-08-31 14:53, Arno Welzel wrote:
> 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?[...]

I realize my wording was ambiguous. I *don't* want the French text
to become an attachment.

I haven't yet worked out the right sequence of incantations, but at
least you have given me a lead. Thanks.

> [...]
>
> 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.

Again, thanks.

Jeroen Belleman

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

<630ff4c5$0$690$14726298@news.sunsite.dk>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=652&group=comp.lang.php#652

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail
Date: Wed, 31 Aug 2022 19:54:40 -0400
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.13.0
Subject: Re: PHP mail() turns text with special characters into attachments
Content-Language: en-US
Newsgroups: comp.lang.php
References: <teni8h$dar$1@gioia.aioe.org>
From: arne@vajhoej.dk (Arne Vajhøj)
In-Reply-To: <teni8h$dar$1@gioia.aioe.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 32
Message-ID: <630ff4c5$0$690$14726298@news.sunsite.dk>
Organization: SunSITE.dk - Supporting Open source
NNTP-Posting-Host: 75168362.news.sunsite.dk
X-Trace: 1661990085 news.sunsite.dk 690 arne@vajhoej.dk/68.9.63.232:56286
X-Complaints-To: staff@sunsite.dk
 by: Arne Vajhøj - Wed, 31 Aug 2022 23:54 UTC

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.

Arne

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

<teq89c$g8d$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=653&group=comp.lang.php#653

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!aioe.org!ICt92rkpUtdiBkqMoKbPBQ.user.46.165.242.91.POSTED!not-for-mail
From: jeroen@nospam.please (Jeroen Belleman)
Newsgroups: comp.lang.php
Subject: Re: PHP mail() turns text with special characters into attachments
Date: Thu, 01 Sep 2022 14:24:12 +0200
Organization: Aioe.org NNTP Server
Message-ID: <teq89c$g8d$1@gioia.aioe.org>
References: <teni8h$dar$1@gioia.aioe.org> <630ff4c5$0$690$14726298@news.sunsite.dk>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="16653"; posting-host="ICt92rkpUtdiBkqMoKbPBQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0
X-Notice: Filtered by postfilter v. 0.9.2
 by: Jeroen Belleman - Thu, 1 Sep 2022 12:24 UTC

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

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

<jndp8rFhtqpU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=656&group=comp.lang.php#656

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: usenet@arnowelzel.de (Arno Welzel)
Newsgroups: comp.lang.php
Subject: Re: PHP mail() turns text with special characters into attachments
Date: Fri, 2 Sep 2022 09:22:02 +0200
Lines: 19
Message-ID: <jndp8rFhtqpU1@mid.individual.net>
References: <teni8h$dar$1@gioia.aioe.org> <jn93uiFpvo0U1@mid.individual.net>
<tenper$1p5o$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Trace: individual.net hmyMyXRr2ncGzkEjKnYStgSrf74ypEDjxKZCFzHXW8zCqw/4GQ
Cancel-Lock: sha1:KeqvEAVPok+U2WEgCvcZeN6/HlU=
Content-Language: de-DE
In-Reply-To: <tenper$1p5o$1@gioia.aioe.org>
 by: Arno Welzel - Fri, 2 Sep 2022 07:22 UTC

Jeroen Belleman, 2022-08-31 15:58:

> 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.

Then tell that those people who are responsible for the hosting. Keeping
outdated software running just because nobody wants to change anything
is never a good advise. At some point the stuff gets so old that you
literally need to throw it away and create a complete new solution.

--
Arno Welzel
https://arnowelzel.de

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

<dc9831d3-b644-444a-adb0-e28e890e4504n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=672&group=comp.lang.php#672

  copy link   Newsgroups: comp.lang.php
X-Received: by 2002:a05:622a:1014:b0:35c:e8ef:a406 with SMTP id d20-20020a05622a101400b0035ce8efa406mr2972375qte.306.1663855870977;
Thu, 22 Sep 2022 07:11:10 -0700 (PDT)
X-Received: by 2002:a81:b641:0:b0:345:1ca2:7055 with SMTP id
h1-20020a81b641000000b003451ca27055mr3210869ywk.323.1663855870819; Thu, 22
Sep 2022 07:11:10 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.php
Date: Thu, 22 Sep 2022 07:11:10 -0700 (PDT)
In-Reply-To: <teni8h$dar$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=82.131.36.130; posting-account=gin_zAoAAAAxFoHHJeGbYqdKpQ_tFzq7
NNTP-Posting-Host: 82.131.36.130
References: <teni8h$dar$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <dc9831d3-b644-444a-adb0-e28e890e4504n@googlegroups.com>
Subject: Re: PHP mail() turns text with special characters into attachments
From: he1983912@aol.com (He, who travels time to time)
Injection-Date: Thu, 22 Sep 2022 14:11:10 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2027
 by: He, who travels time - Thu, 22 Sep 2022 14:11 UTC

Hey... Want to talk? Call me.... My telephone number >>>>

(+372) 56330687

Jeroen Belleman kirjutas Kolmapäev, 31. august 2022 kl 14:56:15 UTC+3:
> 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

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor