Fork me on GitHub
Subscribe 6

Ticket #830 (fixed bug)

Problem with PHP_EOL constant and email.php

  • Created: 2013-02-11 03:13:36
  • Reported by: barbuslex
  • Assigned to: JohnLewis
  • Milestone: 1.5.4
  • Component: code
  • Priority: normal

Hi,

I found a problem with utf-8 encoding charset in sending email.

In file email.php we replaced at the last updated the value "\r\n" by the constant PHP_EOL.
Only, on my local server (WampServer on Windows) it works correctly accented characters appear correctly in the mail. (é ==> é)
But, my hosting (Apache + PHP on linux) the charset is wrong escaped. (é ==> é)

include / email.php
The problem is on the line:
$ headers = 'From:'. $ from.PHP_EOL. 'Date'. gmdate ('r'). PHP_EOL. 'MIME-Version: 1.0'. PHP_EOL. 'Content-transfer-encoding: 8bit'. PHP_EOL. 'Content-type: text / plain; charset = utf-8 '. PHP_EOL.' X-Mailer: FluxBB Mailer ';

History

Studio384 2013-02-11 11:10:10

  • Milestone set to 1.5.3.

Franz 2013-02-22 11:11:53

  • Milestone changed from 1.5.3 to 1.5.4.

quy 2013-02-27 15:53:00

Please revert the change as stated here and test to see if PHP_EOL is the culprit.

Also, which PHP version is installed with your hosting?

Comment edited 1 times (Diff)

quy 2013-03-30 04:00:37

  • Status changed from open to worksforme.

Closing for now until we get more information from this user.

barbuslex 2013-05-29 11:57:20

PHP : 5.2.17

Franz 2013-05-29 12:32:29

Did this work for you?

Quy wrote:

Please revert the change as stated here and test to see if PHP_EOL is the culprit.

barbuslex 2013-05-29 15:20:37

Yes its works when i revert the code

Franz 2013-05-29 15:24:09

  • Status changed from worksforme to open.

JohnLewis 2013-07-29 17:51:54

  • Owner set to JohnLewis.

A revert? Sure.

JohnLewis 2013-07-29 17:58:07

Commit 7062c9d to fluxbb master

#830: Revert use of PHP_EOL in email.php

JohnLewis 2013-07-29 18:02:03

Pulled. Waiting for merge.

Oldskool 2013-07-30 12:37:56

Commit 17d9080 to fluxbb master

Merge pull request #84 from JohnFLewis/patch-2

#830: Revert use of PHP_EOL in email.php

JohnLewis 2013-07-30 13:49:07

  • Status changed from open to fixed.

sklerder 2013-09-04 19:29:09

Following the piece of discussion here, could this bug be reopened ?

The proposal of solution would be the following :
- First, define a "FLUXBB_EOL" constant in "/config.php" :

// To handle line breaks in mail headers
// possible values can be : PHP_EOL, "\r\n", "\n" or "\r"
// Original value is PHP_EOL (handled by the OS)
define ('FLUXBB_EOL', PHP_EOL);

- Then, modify the two lines defining "$headers" that were modified by 1.5.4 in "/include/email.php" :

	$headers = 'From: '.$from.FLUXBB_EOL.'Date: '.gmdate('r').FLUXBB_EOL.'MIME-Version: 1.0'.FLUXBB_EOL.'Content-transfer-encoding: 8bit'.FLUXBB_EOL.'Content-type: text/plain; charset=utf-8'.FLUXBB_EOL.'X-Mailer: FluxBB Mailer';

	// If we specified a reply-to email, we deal with it here
	if (!empty($reply_to_email))
	{
		$reply_to = '"'.encode_mail_text($reply_to_name).'" <'.$reply_to_email.'>';

		$headers .= FLUXBB_EOL.'Reply-To: '.$reply_to;

And the results, on CentOS 6.3 with Postfix 2.6.6 as MTA :
- With FLUXBB_EOL defined to PHP_EOL, it's OK (headers are not broken, UTF-8 is OK)
- With FLUXBB_EOL defined to "\n", it's OK (headers are not broken, UTF-8 is OK)
- With FLUXBB_EOL defined to "\r\n", it's not OK (headers are broken, UTF-8 is bad)
- With FLUXBB_EOL defined to "\r", it's not OK (headers are not broken, UTF-8 is bad)

Studio384 2013-09-04 19:31:30

I don't know if we reopen tickets in an already closed milestone. I think a new ticket is a better idea.

sklerder 2013-09-04 19:36:02

Sorry if it was a mistake ...

Is it possible, in this case, to move the request to a new ticket, or should I fill another bug ?

Studio384 2013-09-04 19:41:46

Fill another bug wink