Hi Uri, Without entering any political fight with you here on this list (or elsewhere) - Your script to send emails to MK from your site, WILL get your site's mail blocked and marked as SPAM (as well as being marked as spammer in RBL etc...)
Please note: the guys in the goverment who do monitor the mail servers for the goverment are also subscribed to this mailing list (and no, I'm not one of them). Thanks, Hetz On 3/7/07, Uri Even-Chen <[EMAIL PROTECTED]> wrote:
Hi people, I wrote a PHP program that sends E-mail to 121 E-mail addresses at once [http://www.speedy.net/knesset/]. The problem is, it takes many seconds until the program completes sending all the E-mails. I want to give the user an instant feedback, and send E-mails later (after the HTML output is complete). How do I do it? Can I postpone the mail sending function? My program calls sendmail 121 times, and I think that's the only slow part of the program. The rest is quite fast. Can I call sendmail in such a way that PHP will regain control right away? Or alternatively, can I run another PHP script in the background? Below is my mail sending script. Uri. <?php $tmp_addresses_clone= $tmp_addresses; // Flush the output buffer. ob_flush(); flush(); $tmp_count= count($tmp_addresses_clone); while ($tmp_count > 0) { $tmp_random= rand(0, $tmp_count - 1); // Open Mail Command. $tmp_mail_command= '/usr/sbin/sendmail -f ' . $tmp_email . ' ' . $tmp_addresses_clone[$tmp_random] . ' > /dev/null 2>&1'; $tmp_mail_file_pointer= popen($tmp_mail_command, "w"); if ($tmp_mail_file_pointer) { // Print mail header. fputs($tmp_mail_file_pointer, "From: " . '=?UTF-8?B?' . base64_encode($tmp_name) . '?=' . ' ' . '<' . $tmp_email . '>' . "\n"); fputs($tmp_mail_file_pointer, "To: " . $tmp_addresses_clone[$tmp_random] . "\n"); fputs($tmp_mail_file_pointer, "Subject: " . '=?UTF-8?B?' . base64_encode($tmp_subject) . '?=' . "\n"); fputs($tmp_mail_file_pointer, "MIME-Version: 1.0\n"); fputs($tmp_mail_file_pointer, "Content-Type: text/plain; charset=UTF-8\n"); fputs($tmp_mail_file_pointer, "\n"); // Print mail body. fputs($tmp_mail_file_pointer, $tmp_content . "\n"); fputs($tmp_mail_file_pointer, "\n"); // Close file. pclose($tmp_mail_file_pointer); } echo ($tmp_addresses_clone[$tmp_random] . '<br>' . "\n"); $tmp_addresses_clone[$tmp_random]= $tmp_addresses_clone[$tmp_count - 1]; unset($tmp_addresses_clone[$tmp_count - 1]); // Flush the output buffer. ob_flush(); flush(); $tmp_count= count($tmp_addresses_clone); } ?> ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
-- Skepticism is the lazy person's default position. Visit my blog (hebrew) for things that (sometimes) matter: http://wp.dad-answers.com ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
