Mail, array of recipients

From: Date: Fri, 06 Aug 2004 22:08:30 +0000
Subject: Mail, array of recipients
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-13990@lists.php.net to get a copy of this message
In the pear manual examples for the send method, it shows: send (mixed $recipients, string $headers, string $body); When I send out an e-mail from an app, it works, however, it does not seem to properly populate the "To" header based on the recipient array. What I mean by that is if I examine the headers after having received the email, the "To" header is completely missing. If I manually set the "To" header, it works. However, as you can imagine, unless my recipient array has only one person, this method wouldn't work. I'd have to loop through each individual in the recipient array, create a new object, then call the method again and again. Here's a snip from my code: $recipients = array('someone@example.com','someoneelse@example.com'); $smtparray = array(); $smtparray["host"] = 'smtp.example.com'; $smtparray["auth"] = FALSE; $crlf = "\r\n"; $from = "me@example.com (Web Master)"; $hdrs = array(); $hdrs["From"] = $from; $hdrs["Subject"] = $subject; $hdrs["Reply-To"] = $from_address; $mime = new Mail_mime($crlf); $mime->setTXTBody($plaintextmessage); $mime->setHTMLBody($htmlmessage); $body = $mime->get(); $hdrs = $mime->headers($hdrs); $mailObj =& Mail::factory('smtp',$smtparray); if (isset($recipients) && ($recipients)) { $result = $mailObj->send($recipients, $hdrs, $body); if (PEAR::isError($result)) { return $result -> getMessage(); } else { return "Success."; } } else { return "Your e-mail has NOT been sent.<br>Please select at least one recipient."; } Has anyone run into this? Is there a fix? Thanks,

« previous php.pear.general (#13990) next »