...

View Full Version : OPEN SINGLE CONNECTION TO SEND 1000s OF EMAILS



dhtmlhelp
03-29-2003, 04:48 PM
Hi,

I need to be able to use PHP to open a connection to the mail server and then send hundreds or thousands of emails before closing the connection.

Currently I use the PHP mail() function - each time I use this function it opens a connection to the mail server, sends 1 email, the closes the connection. This is very inefficient if you are trying to send thousands of emails at a time.

Can anybody suggest a solution to this problem?

DHTMLHELP

stoodder
03-29-2003, 05:11 PM
hmm maybe you could use the loop function


<?php
mysql_cnnect(localhost, Username, Password);
mysql_select_db(Database);
$sql = "SELECT * FROM $Table";
$query = mysql_query($sql);
$num = mysql_num_rows($query);

for($i=1;$i<=$num;i++) {
$fetch = mysql_fetch_row($query);
$message = "you are now reviing our news letter";
$message .= $fetch['username'];
mail ($fetch['Email'], "YOUREMAIL@YOU.COM", $message)
}
?>


i dont know if that helps please give me yor feed i hope it does lol

Nightfire
03-29-2003, 05:23 PM
I've never found a way to do it, there must be a way somehow though.

stoodder, your way still opens the connection and closes it for each email :)

dhtmlhelp
03-29-2003, 06:20 PM
Yes, that won't do it.

Anyone would like to reveal the secret?

DH

krycek
03-29-2003, 06:36 PM
yup, I can do it :)

I have written my own replacement for mail() a while back... I actually posted it on these forums a couple of weeks ago, go search!

Currently it is simply a drop-in replacement for mail(), but due to some work I am doing for a client over the next week or so, I am going to be adding some extras. One of which, that is already working, is the ability to open a socket ONCE and send maultiple emails. In fact, that's quite easy and if you look at the scripts I posted before, you may even be able to do it yourself ;)

Otherwise, you'll have to wait till I finish it... :p

::] krycek [::

dhtmlhelp
03-29-2003, 08:47 PM
Hi Krycek,

where can I take a look at your script, I couldn't find it ... yet.

Please let me know just in case.

thanks,

DH

krycek
03-30-2003, 01:11 AM
http://www.codingforums.com/showthread.php?s=&threadid=16501 :)

::] krycek [::

missing-score
03-30-2003, 09:37 AM
I think you may need to use the fsockopen() function. I think... :rolleyes:

krycek
03-30-2003, 11:18 AM
Originally posted by missing-score
I think you may need to use the fsockopen() function. I think... :rolleyes:

...take a look at my script ;)

::] krycek [::

missing-score
03-30-2003, 01:58 PM
I posted the message then I looked at the script. I have seen it used in a similar thing before, a SMTP function from somewhere else.

krycek
03-30-2003, 03:16 PM
yup, since I first made that script, I have seen it pop up in a few other places :rolleyes: sometimes people give me credit, sometimes they don't :p

::] krycek [::



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum