Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    127
    Thanks
    0
    Thanked 0 Times in 0 Posts

    OPEN SINGLE CONNECTION TO SEND 1000s OF EMAILS

    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

  • #2
    Regular Coder
    Join Date
    Oct 2002
    Location
    Milwaukee, Wisconsin
    Posts
    123
    Thanks
    1
    Thanked 0 Times in 0 Posts
    hmm maybe you could use the loop function
    PHP Code:
    <?php
    mysql_cnnect
    (localhostUsernamePassword);
    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

  • #3
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    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

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    127
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, that won't do it.

    Anyone would like to reveal the secret?

    DH

  • #5
    Regular Coder
    Join Date
    Nov 2002
    Location
    Bristol, UK
    Posts
    932
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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...

    ::] krycek [::
    ithium | SOAPI | SDP | PTPScript manual
    "ithium is a non-profit webhost, which is pretty much unique. The mission of ithium is to provide free hosting resources for worthwhile and needy non-profit projects, which otherwise may not be able to obtain such facilities. The money from commercial customers goes to maintain ithium's servers and further development."

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    127
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #7
    Regular Coder
    Join Date
    Nov 2002
    Location
    Bristol, UK
    Posts
    932
    Thanks
    0
    Thanked 0 Times in 0 Posts
    emails in php

    ::] krycek [::
    ithium | SOAPI | SDP | PTPScript manual
    "ithium is a non-profit webhost, which is pretty much unique. The mission of ithium is to provide free hosting resources for worthwhile and needy non-profit projects, which otherwise may not be able to obtain such facilities. The money from commercial customers goes to maintain ithium's servers and further development."

  • #8
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think you may need to use the fsockopen() function. I think...

  • #9
    Regular Coder
    Join Date
    Nov 2002
    Location
    Bristol, UK
    Posts
    932
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by missing-score
    I think you may need to use the fsockopen() function. I think...
    ...take a look at my script

    ::] krycek [::
    ithium | SOAPI | SDP | PTPScript manual
    "ithium is a non-profit webhost, which is pretty much unique. The mission of ithium is to provide free hosting resources for worthwhile and needy non-profit projects, which otherwise may not be able to obtain such facilities. The money from commercial customers goes to maintain ithium's servers and further development."

  • #10
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts

    yeah...

    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.

  • #11
    Regular Coder
    Join Date
    Nov 2002
    Location
    Bristol, UK
    Posts
    932
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yup, since I first made that script, I have seen it pop up in a few other places sometimes people give me credit, sometimes they don't

    ::] krycek [::
    ithium | SOAPI | SDP | PTPScript manual
    "ithium is a non-profit webhost, which is pretty much unique. The mission of ithium is to provide free hosting resources for worthwhile and needy non-profit projects, which otherwise may not be able to obtain such facilities. The money from commercial customers goes to maintain ithium's servers and further development."


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •