Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.4.1

Bug #2768 Points in From are not validated
Submitted: 2004-11-16 09:17 UTC
From: garak Assigned: jon
Status: Bogus Package: Mail
PHP Version: 4.3.9 OS: Linux 2.4.26
Roadmaps: (Not assigned)    
Subscription  


 [2004-11-16 09:17 UTC] garak
Description: ------------ Points in "From" field are not validated by Mail/RFC822.php The "send" method return a PEAR error. Reproduce code: --------------- <?php require_once 'Mail.php'; $headers['From'] = 'example.com staff <staff@example.com>'; $headers['To'] = 'garak@example.com'; $headers['Subject'] = 'test PEAR::Mail'; $text = 'ciao'; $mail =& Mail::factory('smtp', array('host' => 'smtp.example.com')); $ret = $mail->send($headers['To'], $headers, $text); var_dump($ret); ?> Expected result: ---------------- bool(true) Actual result: -------------- object(pear_error)(8) { ["error_message_prefix"]=> string(0) "" ["mode"]=> int(1) ["level"]=> int(1024) ["code"]=> NULL ["message"]=> string(61) "Validation failed for "example.com staff "" ["userinfo"]=> NULL ["backtrace"]=> [...snip...] }

Comments

 [2004-11-26 15:45 UTC] abulman at gmail dot com
This is quite likely to be related to this change http://cvs.php.net/diff.php/pear/Mail/Mail/RFC822.php?r1=1.17&r2=1.18&ty=h 'Section 6.2.4 of RFC 822 states that the "local part" of the address may not contain unquoted spaces.' When the line is changed to $headers['From']='"example.com staff" <staff@example.com>'; // note the internal quotes surrounding the text it returns the expected result. There may additionally be some confusion over the meaning of 'local part'.
 [2004-11-27 22:07 UTC] jon
Your example appears to work fine using Mail 1.1.4. Can you give that a try?
 [2004-11-29 08:52 UTC] garak
I used Mail 1.4 even before. The only way to get it working is to surround the name with quotes: $headers['From'] = '"example.com staff" <staff@example.com>';
 [2004-11-29 16:47 UTC] jon
After re-reading the relevant sections of RFC 822, I believe the code is correct, and you'll need to quote the local part of the address if it contains embedded periods (points).