#44170 [NEW]: mail() function arguments ambiguity

From: Date: Tue, 19 Feb 2008 14:39:15 +0000
Subject: #44170 [NEW]: mail() function arguments ambiguity
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-530@lists.php.net to get a copy of this message
From: marijn at monomelodies dot nl Operating system: irrelevant PHP version: Irrelevant PHP Bug Type: Documentation problem Bug description: mail() function arguments ambiguity Description: ------------ The docs for the mail() function state the first parameter ($to) as being obligatory. They also state that "the formatting of this string must comply with » RFC 2822". This would lead me to expect that passing a string not containing a valid address would cause a warning or at least a notice. This isn't so. While technically I'm fairly sure this is correct behaviour (AFAICT RFC 2822 states that either To, Cc or Bcc should be included, so leaving *out* To shouldn't be a problem and in fact isn't, and non-email addresses are also supported) the docs suggest that under PHP it is in fact illegal. I would expect that passing NULL or an empty string would result in the entire To: field being omitted in the headers (it's now in fact empty, which doesn't seem to conform to RFC 2822 which says that if you *do* include any such header it should contain a comma-separated list of at *least* 1 address). Whether or not a notice should follow something that doesn't appear to be an emailaddress is a matter for debate - I'd personally leave regexing to the users of the function, but then the manual isn't correct. So, actually it's something of a bug/feature in the mail() function as well I believe, and passing NULL as the first parameter should cause the To-header to be omitted. But since including a To-header seems like good form mostly the docs are, I feel, somewhat incomplete in this respect. Reproduce code: --------------- <?php mail( NULL, 'test', NULL, <<<EOT Bcc: marijn@monomelodies.nl test EOT ); Expected result: ---------------- Depending on how you feel about $to being obligatory, either a better-formed email being sent, or a notice or even warning thrown by PHP. Actual result: -------------- [...snip...] To: <-- violates RFC 2822 Subject: test test -- Edit bug report at http://bugs.php.net/?id=44170&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44170&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44170&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44170&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=44170&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=44170&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=44170&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=44170&r=needscript Try newer version: http://bugs.php.net/fix.php?id=44170&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=44170&r=support Expected behavior: http://bugs.php.net/fix.php?id=44170&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=44170&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=44170&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=44170&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44170&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=44170&r=dst IIS Stability: http://bugs.php.net/fix.php?id=44170&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=44170&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=44170&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=44170&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=44170&r=mysqlcfg

« previous php.doc.bugs (#530) next »