critical "doc bugs" in Mail

From: Date: Thu, 01 Aug 2002 18:42:18 +0000
Subject: critical "doc bugs" in Mail
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-8135@lists.php.net to get a copy of this message
Hi I've been using the Mail package today to send different sorts of emails using SMTP, and there are some points that in my opinion HAVE to be added in the doc. 1st, one that is known i think, but that has cost me a correct amount of time: the fact that the call to Mime_Mail::headers() has to be done AFTER Mime_Mail::get(). I know that it is correct in the sample, but it should be explicitely added. 2nd, a Mime email sent using Mime_Mail and Mail::factory('mail') will be incorrect with the default settings: the default CRLF char used is \r\n, and it crashes when the message is sent using the mail driver. It has to be \n, and it is nowhere to be found on the documentation... on the other hand, \r\n is recommended with SMTP, but \n works. Quite confusing. 3rd, you have to reset the internal Mail::_headers member variable if you want to change a header item in an email that has already been generated. Here was my scenario: <?php $headers = array( ... 'Subject' => 'a subject', 'To' => 'pear-dev@lists.php.net', ... ); $mime->setHTMLBody($somevar); $mail =& new Mail::factory('smtp'); $body = $mime->get(); $hdrs = $mime->headers($headers); $mail->send($recipient, $hdrs, $body); // The email is sent, it works // now we want to send the same message to someone else // with a diff. subject $headers['Subject'] = 'another subject'; $headers['To'] = 'Another Recipient <anotherrecipient@foobar.com>'; $mail->send($other_recipient, $mime->headers($headers), $body); // The email is sent to $other_recipient, // but with the subject 'a subject', // and the 'To' header 'another recipient...'. ?> Since Mail::_headers is an interval variable, it should not be modified by the user itself. I hope i didn't ask RTFM questions. -- Katana / Bertrand

« previous php.pear.dev (#8135) next »