I wouldn't call this a real solution, since it relies heavily on specific server requirements and config changes. Simple fact is that a LOT of PHP programmers are on shared servers, and their hosts would NOT want 50,000 emails queued up on disk. No way!!
I'd expect doing this frequently on a shared server would be the fastest way to get your account shut down. Justin French on 17/08/02 6:37 AM, Daren Cotter ([EMAIL PROTECTED]) wrote: > I have found a solution to my bulk email problem. I'm > posting my solution simply because I spent nearly a > year finding it, and I KNOW there's many other people > in my same situation. > > First, a recap of my problem: > > I need to send personalized emails to my member list > on a daily basis. I use PHP to query the MySQL > database, and loop through the results using the > mail() function. Problem: very slow, browser/php times > out, etc. > > Solution: > > First, I configure sendmail to use "queueonly" as the > DeliveryMethod (see sendmail.cf) instead of > "background". Then, when my PHP script runs, mailings > simply get queued instead of actually delivered. This > is a x10 speed increase. My script queues > approximately 1,000 mailings per minute (a x10 speed > increase). Then, I modified the > /etc/rc.d/init.d/sendmail script to process the queue > every 5 minutes, instead of the default one hour. This > insures that the mailings actually get sent soon after > they're queued, and you won't have to wait for > important emails to come through. > > The problem with the above solution used to be this: > certain emails generated from my site (welcome emails, > password lookup emails, etc) need to be sent > IMMEDIATELY, and cannot wait in the queue for 5 > minutes. The solution for this: not using the built-in > mail() command in PHP. I created my own mail script > (by modifying something someone else already did) > which opens a socket directly with the mail server. > Code is below. > > // Sends the email directly to the mail server using > SMTP. This is done > // so sendmail can be setup using the queue method on > the server, and > // confirmation emails, etc, can be sent immediately > to the member. > function smtp_mail($to, $from_name, $from_email, > $reply_to_email, $subject, $body) { > $smtp = fsockopen("your_mail_server_here", 25); > if ($smtp == 0) > return 0; > fputs($smtp,"helo > machines_host_and_domain_name_here\r\n"); > $line = fgets($smtp, 1024); > fputs($smtp,"mail from: $from_email\r\n"); > $line = fgets($smtp, 1024); > fputs($smtp,"rcpt to: $to\r\n"); > $line = fgets($smtp, 1024); > fputs($smtp,"data\r\n"); > $line = fgets($smtp, 1024); > fputs($smtp,"From: $from_name <$from_email>\r\n"); > fputs($smtp,"Reply-To: $reply_to_email\r\n"); > fputs($smtp,"To: $to\r\n"); > fputs($smtp,"Subject: $subject\r\n"); > fputs($smtp,"\r\n"); > fputs($smtp,"$body\r\n"); > fputs($smtp,".\r\n"); > $line = fgets($smtp, 1024); > fputs($smtp, "QUIT\r\n"); > fclose($smtp); > return 1; > } > > Function is called as follows: > > if (!smtp_mail("recipient_email_here", > $EMAIL_FROM_NAME, $EMAIL_FROM_EMAIL, > $EMAIL_FROM_REPLY_TO, $SIGNUP_VALIDATION_SUBJECT, > "Test Body")) { > print "error: mail not sent"; > } else { > print "it worked!"; > } > > Hope this helps others! > > __________________________________________________ > Do You Yahoo!? > HotJobs - Search Thousands of New Jobs > http://www.hotjobs.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php