Page 1 of 1
Mass Email???
Posted: Tue Jan 20, 2004 3:53 am
by Mr. Tech
I have asked this question before but never got the answer I wanted...
I want to set up a script where I can send out a mass email to my 6000+ mailing list subscribers...
How would be the best way to do this without any time outs etc...
Thanks!
Posted: Tue Jan 20, 2004 4:14 am
by JayBird
I would not recommend using the mail() function in PHP for anything over 100 mails, not even using it by breaking out your recipients in batches of 25, 50, 100 etc. and looping with the function.
The mail function in general is pretty weak - your best option would be to open a socket to SMTP and package up the mail in an env and send it at once by using 'RCPT TO:' in the SMTP connection.
Make your connection by using
fsockopen() or
popen().
Look through the user notes on fsockopen() and you will see a few examples of sending mail to SMTP using this...
Mark
Posted: Tue Jan 20, 2004 5:21 pm
by Mr. Tech
Is this the sort of thing:
Code: Select all
<?php
function httpPost($host, $path, $referer, $data) {
$fp = fsockopen($host, 80);
fputs($fp, "POST ".$path." HTTP/1.0\r\n");
fputs($fp, "Host: ".$host."\r\n");
fputs($fh, "Referer: ".$referer."\r\n");
fputs($fp, "Content-type: application/x-www-url-encoded\r\n");
fputs($fp, "Content-length: ".strlen($data)."\r\n");
fputs($fp, "\r\n");
fputs($fp, $data."\r\n");
fputs($fp, "\r\n");
$tmp_headers = "";
while ($str = trim(fgets($fp, 4096)))
$tmp_headers .= $str."\n";
$tmp_body = "";
while (!feof($fp))
$tmp_body .= fgets($fp, 4096);
fclose($fp);
return $tmp_body;
}
?>
What would I put in the host, $path, $referer and $data fields?