Re: sending multipule email with mail ()

From: Date: Mon, 26 Jun 2000 18:09:40 +0000
Subject: Re: sending multipule email with mail ()
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-3154@lists.php.net to get a copy of this message
On Tue, 27 Jun 2000, Mark Lo wrote: > I know how to use the mail funtion, but how to use the mail > function to send multiple email messages to different person. Should I > use the mail () inside a while loop if all of the email address is > stored in the database. Is this a formal way to send multiple email. > Any suggestion is helpful. > > example. > > While ($row=mysql_fetch_row($result)) > { > mail function > > } My suggestion would be to run your fetch and add it to an arrayL while ( $row=mysql_fetch_row( $result ) ) $to_addr[count($too_addr)] = $row["email_address"]; Then all you have to do is implode the $too_addr array and send your email: $to = implode( ",", $to_addr ); mail( $to, $subject, $body ); This of course assumes you want to send all users the same message. Advantage: One call to sendmail Disadvantage: could be slow if your sendmail is configured to wait for DNS Also, keep in mind that I can't even send simple emails yet. :) -- Don Faulkner, MCP | Senior Security Analyst | Spectria <don.faulkner@infosec.spectria.com> | --A division of Rainbow Technologies | 1-888-IS-GUARD

« previous php.general (#3154) next »