View Issue Details

IDProjectCategoryView StatusLast Update
0012216mantisbtdocumentationpublic2010-09-11 17:18
ReporterAlexRosa Assigned Togiallu  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionno change required 
Product Version1.2.1 
Target Version1.2.3 
Summary0012216: Minimal PHP 5.2 version is 5.2.9
Description

The documentation says the minimal 5.2 version is 5.2.0 but this version has the bug 47282 that prevents Mantis to send email to local network addresses (like user@box). The PHP bug report is here:

http://bugs.php.net/bug.php?id=47282

This PHP bug was related to FILTER_VALIDATE_EMAIL, used by the phpMailer library that Mantis 1.2.1 uses. It was fixed in PHP 5.2.9, according to the following change log:

http://www.php.net/ChangeLog-5.php#5.2.9

Steps To Reproduce

1) Install Mantis 1.2.1 with PHP 5.2.x where x < 9
2) Use local network addresses like user@box
3) Try to send emails -- they will raise "Invalid Address" in phpMailer

Additional Information

My suggestion is to update the documentation to: a) raise the minimum version of PHP 5.2 to 5.2.9 or b) include a warning mentioning this problem with local network addresses for PHP 5.2 versions below 5.2.9.

TagsNo tags attached.
Attached Files
local_network.patch (618 bytes)   
--- class.phpmailer.php	2010-08-05 12:30:13.000000000 -0300
+++ /var/www/mantisbt-1.2.2/library/phpmailer/class.phpmailer.php	2010-07-29 13:45:22.000000000 -0300
@@ -522,7 +522,7 @@
    */
   public static function ValidateAddress($address) {
     if (function_exists('filter_var')) { //Introduced in PHP 5.2
-      if(this-Mailer != 'mail' && filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {
+      if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {
         return false;
       } else {
         return true;
@@ -2317,4 +2317,4 @@
     return $errorMsg;
   }
 }
-?>
+?>
\ No newline at end of file
local_network.patch (618 bytes)   

Activities

AlexRosa

AlexRosa

2010-07-29 10:40

reporter   ~0026168

To find the line of phpMailer that triggers the PHP bug, run this grep:
grep FILTER_VALIDATE_EMAIL library/phpmailer/class.phpmailer.php

AlexRosa

AlexRosa

2010-08-05 14:02

reporter   ~0026229

Bad news: the bug was reintroduced in PHP 5.2.14 and probably occurs also in recent 5.3.x versions. Local networks emails are considered invalid by the RFC's used as specs by PHP team -- they consider SMTP only. Since PHPMailer does support the mail() method, the problem is with them. I've submitted an ISSUE at PHPMailer bugtracking mentioning this.

The current workaround is to edit .../library/phpmailer/class.phpmailer.php at line 525, adding a test to check if the current method is mail():

if(this-Mailer != 'mail' && filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {

Patch is attached.

AlexRosa

AlexRosa

2010-08-05 14:04

reporter   ~0026230

Sorry the patch was made in the wrong direction, but you get my point.

micahg

micahg

2010-08-05 18:01

reporter   ~0026235

Just want to point out that Ubuntu Hardy shipped with PHP 5.2.4 and Debian Lenny with 5.2.6. Hardy is supported on the server until April 2013 and Lenny has a year of support after the next release comes out. I would request not exceeding 5.2.6 if possible until Lenny is EOL.

AlexRosa

AlexRosa

2010-08-09 09:52

reporter   ~0026248

Here is the bug report for PHPMailer:
http://sourceforge.net/tracker/?func=detail&aid=3040090&group_id=26031&atid=385707

AlexRosa

AlexRosa

2010-08-20 13:48

reporter   ~0026386

Just to clarify: the problem is not the PHP version, it's the PHPMailer function "ValidateAddress" that uses PHP's FILTER_VALIDATE_EMAIL filter for all emails, including local network addresses that are valid when then "mail" method is used.

giallu

giallu

2010-08-23 17:40

reporter   ~0026430

Uhm, I wonder what dragged requirements to 5.2. I remember it was discussed several times and generally agreed we were trying to stick to 5.1 for the 1.2 release and raise the bar afterwards

dhx

dhx

2010-08-23 21:22

reporter   ~0026432

Most of MantisBT should work fine with PHP 5.1.x. Even this server (mantisbt.org) runs the RHEL 5.1 build of PHP afaik.

AlexRosa

AlexRosa

2010-08-24 08:30

reporter   ~0026449

Maybe I should sumbit a NEW issue, because the problem is NOT the PHP version anymore (they changed back to the old behaviour in 5.2.14). Actually the problem is in PHPMailer library that always uses the standard FILTER_VALIDATE_EMAIL from PHP even when sending emails thru mail() method -- that can accept local network addresses. My patch above fixes PHPMailer.

giallu

giallu

2010-09-08 19:00

reporter   ~0026637

Yeah, please open up a new issue, better if directly upstream at:

http://sourceforge.net/tracker/?group_id=26031

AlexRosa

AlexRosa

2010-09-09 08:51

reporter   ~0026646

Already did that, giallu:
http://sourceforge.net/tracker/?func=detail&aid=3040090&group_id=26031&atid=385707

AlexRosa

AlexRosa

2010-09-10 09:38

reporter   ~0026673

This issue can be closed now, there's a new one (12335) about the same problem that is more correct and specific.

giallu

giallu

2010-09-11 17:18

reporter   ~0026676

Ok. thank you very much