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 3 of 3

Thread: Email List

  1. #1
    Regular Coder
    Join Date
    May 2011
    Posts
    124
    Thanks
    12
    Thanked 6 Times in 6 Posts

    Email List

    Need a little help on an email list script.

    I want to store email messages in a database, and then loop through any of those messages that haven't been sent to every single member listed in my members list. I'm on 1&1 and they only permit 55 emails sent every 5 minutes. So I have to do this with a Cron Job.

    How would I make it so the script pulls one email message at a time, sends the email to each member in the members database, then marks the email as sent in the message database, and resets the "sent" column in the members database back to 0.

    Maybe I should include the most recent message id sent for each members row?

    Here's my database structure:

    mailing_list
    | id | name | email | sent |
    | 1 | Test | Test@example.com | 0 |

    mailing_list_messages
    | id | message | email_sent |
    | 1 | Test Message | 0 |
    | 2 | Test Message 2 | 0 |
    PHP Code:
    $mailing_list_result=mysqli_query($mailing_list_db"SELECT `name`, `email` 
    FROM `mailing_list` WHERE `sent`=0 LIMIT 0, 55"
    );

    $mailing_list_count=mysqli_num_rows($mailing_list_result);

    if(
    $mailing_list_count==0){
    $reset_email_id_result=mysqli_query($mailing_list_db"UPDATE 
    `mailing_list_mesages` SET `email_sent`=1 WHERE `email_id`=?"
    );

    $reset_result=mysqli_query($mailing_list_db"UPDATE `mailing_list` SET 
    `sent`=0"
    );
    }
    else{
    //Database Pull for Email message
    //Mail PHP

    Last edited by HDRebel88; 01-21-2013 at 08:28 AM.

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,472
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    How often do you have to email 'everyone' in the list? I'm just curious.
    Once per day, once per week?


    EDIT:
    You also have the problem where if you have more than 55 people, you need to
    know when ALL of them have received the email message. So it looks like you
    might have multiple email messages to send. I'm assuming those email messages
    need to be sent in order of how they appear?

    Doing the limit of 55 will result in only 55 names, and you'll send out a message
    to them ... but the next time it runs, you'll need to know which of the remaining
    people didn't get the message, and WHICH message are you working on? It looks
    like you could have like 10 messages in the queue waiting to be sent?

    How many email addresses do you think you'll have now or in two years from now?
    Will you have hundreds, thousands?

    I think the answer to your problem will depend on how often email messages are
    sent, and how many recipients you have.



    .
    Last edited by mlseim; 01-21-2013 at 01:13 PM.

  • #3
    Regular Coder
    Join Date
    May 2011
    Posts
    124
    Thanks
    12
    Thanked 6 Times in 6 Posts
    Yeah, we'd be looking at 10k+ addresses... I'm just going to be using a previously developed script. ListMessenger; just seems easier that way.


  •  

    Posting Permissions

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