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)    

 [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'] = ' staff <>'; $headers['To'] = ''; $headers['Subject'] = 'test PEAR::Mail'; $text = 'ciao'; $mail =& Mail::factory('smtp', array('host' => '')); $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 " staff "" ["userinfo"]=> NULL ["backtrace"]=> [...snip...] }


 [2004-11-26 15:45 UTC] abulman at gmail dot com
This is quite likely to be related to this change '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']='" staff" <>'; // 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'] = '" staff" <>';
 [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).