what is the best way to send mass email in php. let say i want to send 1000 emails. should i send all emails at a time, or should i do looping? i read someone thread, he said that he got error "too much recipient" when sending mass email.. does looping consider as sending mass email? Thanks for helping..
ya u dont want to do all at once, because then the other people will have all the emails, use while statement for it is my suggestion, while or a for statement
Just a tip. I created something similar to send a few hundred thousand e-mails a week. One way to get past spam filters (they were double opt-in emails, but our server was not white listed) is to use something like PHPMailer and connect to a google account. Then send the e-mails using their servers. Much better hit rate . Combine this with google apps and you can send e-mails that originate from your domain name as well. <?php require("class.phpmailer.php"); $mailer = new PHPMailer(); $mailer->IsSMTP(); $mailer->Host = 'ssl://smtp.gmail.com:465'; $mailer->SMTPAuth = TRUE; $mailer->Username = 'x@gmail.com'; // your gmail address $mailer->Password = 'xxx'; // your gmail password $mailer->From = 'x@gmail.com'; // your gmail address $mailer->FromName = 'x'; // who it's from $mailer->Body = 'This is the main body of the email'; $mailer->Subject = 'This is the subject of the email'; $mailer->AddAddress('dude@hmm.co.uk'); // who you're sending to if (!$mailer->Send()) { echo "Message was not sent<br/ >"; echo "Mailer Error: " . $mailer->ErrorInfo; } else { echo "Message has been sent"; } ?> PHP:
My personal solution for this would be a mysql database table that acts as a mail queue and a script that runs once per minute on a cron job, this script would retrieve a number of unsent (WHERE mail_queue.mail_sent = 0) rows from the "mail_queue" and join the "content" and "subject" fields from the "emails" table based on the "mail_queue.emails_id" and build and send the emails. As each email is sent I would update "mail_queue.mail_sent" to 1. (my personal favourite for sending email in PHP is Zend_Mail) DB tables example: mail_queue (fields: id, to_email, from_email, to_name, from_name, emails_id (related to emails table), mail_sent) emails (fields: id, content, subject ) There would also need to be a script or admin system to get the emails into the "mail_queue" table and maybe a small CMS to manage the emails in the "emails" table, or you could just do this with Phpmyadmin. The cron script could also clean up the mail_queue table once a day or so. Just an idea ;-)