I've heard the mail function doesn't do too well when used for mass mailing, does anyone have any experience with this? I will be sending out over 10,000 emails and I was just wondering if anyone could recommend a way to do it. Thanks
I use the function to send out mass mails, iv never had any problems, i rip the email address's out of a mysql database. Something like this: while($row = mysql_fetch_array ($result)) { echo "Mail sent to "; echo $row[0]; echo "<br>"; $to = $row[0]; $subject = "My spam"; $from_header = "From: "; mail($to, $subject, $body, $from_header); } Thanks Steve
Split them 1-100, 101-200, 201-300 etc. or try a mail list manager : www.hotscripts.com/PHP/Scripts_and_Programs/Mailing_List_Managers/index.html
We use PHPmailer and a script that uses pagination so it sends 100 emails at a time. (we send out 2,000 total emails at a time), so we have 20 pages to load. I've wondered if you could set up an auto-refresh to load the next page... a meta-refresh or something?
Absolutely you can set up an auto-refresh for that. I wrote a PHP script that did just this once (the refresh thing, not the mass mailing thing). My script was actually for remotely copying a database from one server to another (even if one was MySQL, say, and the other was Postgres). I used the 'onload' trigger in my page to throw back to the script and start the next portion of code. I never released it because I wasn't sure if anyone else would be interested in it, but it's definitely doable, yes
Right, you should use SMTP to send email (PHP support SMTP functions) Use REFRESH meta (HTML tags) to auto refresh your send-email page (send 100 emails each time) then you can leave it until all emails have been sent.
Thanks jolie, and welcome to the forum, I'll see if I can put something together tonight before I fall asleep.
Hey mr giraph, let us know how ya get on, iv personally never had any problems sending mails upto a thousand at a time but i suppose it varies. The refresh thing is easy to do, its just like how bigdump works....Maybe download that and see how the code works.
i am sending them with mail() function using an idea from ipb and vbulletin. I am sending packages of 200.
The orignal poster is correct, sending via mail() in a loop sucks. SMTP is a good idea. With a few PEAR::MAIL class libs, not all php servers have them by default, we created a mail loop that opens an SMTP socket for each 300 email batch and sends them. Using MIME we can format them properly with the correct headers and the mail usually gets through too. We also use SPF records for our sites and server. mail() opens and closes a socket for each and every email. vBulletin coders can take advantage of batch/SMTP mail with vbmail() using vbmail_start() and vbmail_stop();.
Well I'm using swiftmailer which connects to my smtp server. I just sent 500 emails to myself. About 300 have come in so far, they're slowly coming in. But it seems like it worked. Actually there seems to be something wrong since the text in the messages isn't coming out right. Here's the code I used for sending the e-mails and reconnecting to the smtp server. for($i = 0; $i < 500; $i++) { $swift->send( 'my-email', '"Name" <my-email>', 'Message Subject' ); if($i%100==0) { $swift->close(); $swift = new Swift(new Swift_SMTP_Connection('my SMTP server')); } } Code (markup): I'll update this thread when I get the message text to show up right.
Cron comes after you have an efficient program to run. The point here is creating a more efficient mail loop. Execution is secondary. For execution without cron and using pagination, look at the code in the vBulletin commbull hack. The code to do auto next page is in it.
Ugh, my Dreamhost server has been going up and down the last few days and it really isn't helping the testing of this.
That is very frustrating. I know the experience. But you are kinda hitting it hard. I just downloaded swift to check it out. Lots of files to include. I have to read a bit more and see if I can make the footprint smaller. I'd like to use this over pear for an application to avoid those that use it needing host intrevention to get pear libs installed to PHP. But of course, I'll benchmarh swift against pear too. I mean if pear is as fast, three easy pear commands can get any server ready for pear. That would be nice if we could count on hosts. With swift, we have the footprint of the include files and updates to distribute. With pear, once installed, php updates will deal with pear lib updates automatically. Oh the pros and cons of a php mailer.
It seems when I close the connection and reopen it the message dissapears so it starts sending blank e-mails. $swift->close(); $swift = new Swift(new Swift_SMTP_Connection('My SMTP server')); $swift->addPart($plain_part); $swift->addPart($html_part, 'text/html'); Code (markup): Anyone with experience with swiftmailer that could help would be really appreciated.