Mime_Mail -> a bug or a normal behavior ?
| From: | m-e- | Date: | Wed, 26 Nov 2003 15:32:32 +0000 |
| Subject: | Mime_Mail -> a bug or a normal behavior ? | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-23900@lists.php.net to get a copy of this message | ||
I do not send this message in the pear users mailing list, because, while
asking questions i'm making suggestions.
I tried to use the Mail_Mime and Mail packages for a emailing application.
What this app does : send a mail to each contact in the mailinglist, and
each mail is different (headers and body) from the others. Here is a good
demo of how it works :
<?php
$mail_sender = &Mail::factory ( $mail_backend, $mail_backend_params);
$mail_mime = new Mail_Mime();
$mail_mime->setFrom( $from );
foreach ( $contacts as $contact_key=>$contact_desc ) {
$mail_mime->setTxtBody ( $contact_desc['txtbody'] );
$mail_mime->setHTMLBody ( $contact_desc['htmlbody'] );
$mail_body = $mail_mime->get();
$mail_headers = array (
"To" => $contact_desc['mail'],
"Subject" => $contact_desc['subject']
);
$mail_headers = $mail_mime->headers ( $mail_headers );
$mail_sender->send ( $contact_desc['mail'], $mail_headers, $mail_body);
}
?>
The problem was that the headers were identical for all the sends (the first
set of headers was used for all next sends), certainly because of the
array_merge direction in "headers" method.
After looking in the Mime_Mail sources, i've found the "setFrom",
"setSubject", "addCc", "addBcc" methods, which do not appear in the
documentation. So i decided to use some of them instead of the "headers"
method. And as there's no "setTo" method, i just created one. Was it a good
idea, or is there better practices ? If it was, should not this new method
appear in the official release ?
And, what about the headers method and its behavior, and about the lack of
documentation ?
Sorry, if i'm not very comprehensible (i'm better in french), and if this
message is a bit out of topic.
Thanks for answers.
Anthony.