DragonFire-N[R] Posted August 25, 2007 Share Posted August 25, 2007 I was wondering what would be the best way to mass/bulk e-mail? I imagine something like this: while ( $email = mysql_fetch_array( $emailquery ) ) { mail( $email['email'], $email['to'], $email['message'], 'From: user@aol.com' ); } Wouldn't be the best method. Can someone provide a better method or perhaps a tutorial that introduces a more efficient method of mass/bulk emailing? I'd greatly appreciate it Quote Link to comment Share on other sites More sharing options...
php_tom Posted August 25, 2007 Share Posted August 25, 2007 You mean like example 1 on this page? http://phpmailer.sourceforge.net/extending.html Quote Link to comment Share on other sites More sharing options...
DragonFire-N[R] Posted August 25, 2007 Author Share Posted August 25, 2007 lol, yeah, something like that. Is there not a more efficient method for sending many e-mails other than calling the mail() function every time it goes through a cycle? Quote Link to comment Share on other sites More sharing options...
php_tom Posted August 25, 2007 Share Posted August 25, 2007 You might be able to send the email to yourself, then BCC a whole bunch of people on that email. That way the email server has to deal with sending the mail and you don't have to wait for each individual email to send. But I think some email servers have a max limit on the number of BCC you can do... maybe 100-ish? (not sure) P.S. I hope you're not starting a spam server, LOL! Quote Link to comment Share on other sites More sharing options...
DragonFire-N[R] Posted August 25, 2007 Author Share Posted August 25, 2007 lol, I'm not; I'm trying to create a newsletter but once so many people subscribe to it, it'll start stressing the server having to send all of those e-mails individually and I'm looking for a more efficient method Thanks for the idea though, I may use that. Would it be possible to send Bcc using the PHP mail() function? Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted August 26, 2007 Share Posted August 26, 2007 another thing you need to keep an eye on is your CPU usage ( if its a shared server). If it is, then maybe you should look at only sending 50 emails etc at once, however havign a cron run the script once every 10 minutes over an hour period. If you do this, you woudl need to keep track of who has reeived the mail, so possibly add a field to the DB of "received" or something. Not sure if this is the best aproach, but it sounds good for mass mailing on a shared server. Yours, PC Nerd Quote Link to comment Share on other sites More sharing options...
DragonFire-N[R] Posted August 26, 2007 Author Share Posted August 26, 2007 Thank you PC Nerd for your feedback. When you say "have a cron run the script once every 10 minutes," what exactly do you mean? Is it possible to configure the shared server to execute a PHP script regularly without requiring someone to access the file via HTTP? I appreciate the info from everyone and I will be using all of the ideas Quote Link to comment Share on other sites More sharing options...
php_tom Posted August 26, 2007 Share Posted August 26, 2007 link=topic=156720.msg681092#msg681092 date=1188081703] Would it be possible to send Bcc using the PHP mail() function? Yeah, // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n"; $headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n"; $headers .= 'Cc: birthdayarchive@example.com' . "\r\n"; $headers .= 'Bcc: birthdaycheck@example.com' . "\r\n"; // Mail it mail($to, $subject, $message, $headers); (That's taken from http://www.php.net/manual/en/function.mail.php. The BCC field can have multiple emails, they have to be comma delimited.) Hope it helps. Quote Link to comment Share on other sites More sharing options...
tibberous Posted August 26, 2007 Share Posted August 26, 2007 A cron job is where you have the cron daemon visit a page a regular intervals, normally for queue processing or cleanup or to attack your enemies. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.