Doc #70082 [NEW]: mail() function description should provide right example of multi-part mail
| From: | ikonta at yandex dot ru | Date: | Wed, 15 Jul 2015 11:56:03 +0000 |
| Subject: | Doc #70082 [NEW]: mail() function description should provide right example of multi-part mail | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-12526@lists.php.net to get a copy of this message | ||
From: ikonta at yandex dot ru
Operating system: GNU/Linux 3.x kernel
PHP version: Irrelevant
Package: Mail related
Bug Type: Documentation Problem
Bug description:mail() function description should provide right example of multi-part mail
Description:
------------
---
From manual page: http://www.php.net/function.mail
---
Fix of https://bugs.php.net/bug.php?id=68776 in
php-5.6.10 pointed
rather important miss:
Internet provides many _incorrect_ (!) examples of a widely spread task
sending of multi-part emails (usually â attached files), but official
documentation doesn't provide the correct solution.
Providing slightly modified verified example from Internet, which
correctly sends mails with attached files with php-5.6.11.
Test script:
---------------
<?php
â¦
// Common header:
$mail_header = "From: ".$from_name." <".$from_mail.">\r\n";
$mail_header .= "Reply-To: ".$replyto."\r\n";
$mail_header .= "MIME-Version: 1.0\r\n";
$mail_header .= "Content-Type: multipart/mixed;
boundary=\"".$uid."\"\r\n\r\n";
// Multi-part body:
$mail_body = "--".$uid."\r\n";
$mail_body .= "Content-type:text/plain; charset=iso-8859-1\r\n";
$mail_body .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$mail_body .= $message."\r\n\r\n";
$mail_body .= "--".$uid."\r\n";
$mail_body .= "Content-Type: application/octet-stream;
name=\"".$filename."\"\r\n";
$mail_body .= "Content-Transfer-Encoding: base64\r\n";
$mail_body .= "Content-Disposition: attachment;
filename=\"".$filename."\"\r\n\r\n";
$mail_body .= $content."\r\n\r\n";
$mail_body .= "--".$uid."--";
// Really necessary parametr:
$envelope = "-f" . $from_mail;
//And sending message itself:
mail($mailto, $subject, $mail_body, $mail_header, $envelope);
?>
Expected result:
----------------
I expect to see the quoted script (or some similiar) in list of examples
in http://php.net/manual/en/function.mail.php
Actual result:
--------------
But now I had to search web following error string:
Jul 15 13:20:13 web httpd: PHP Warning: mail(): Multiple or malformed
newlines found in additional_header in /var/www/project/inc/mail.inc on
line 47
Finding mostly old, unsupported, incorrect and incompatible with
php-5.6.10+ examples.
--
Edit bug report at https://bugs.php.net/bug.php?id=70082&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70082&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70082&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70082&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=70082&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=70082&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=70082&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=70082&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=70082&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=70082&r=support
Expected behavior: https://bugs.php.net/fix.php?id=70082&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=70082&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=70082&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=70082&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70082&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=70082&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=70082&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=70082&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70082&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=70082&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=70082&r=mysqlcfg