Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-21-2013, 08:21 AM   PM User | #1
HDRebel88
Regular Coder

 
Join Date: May 2011
Posts: 112
Thanks: 11
Thanked 5 Times in 5 Posts
HDRebel88 is an unknown quantity at this point
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..
HDRebel88 is offline   Reply With Quote
Old 01-21-2013, 12:29 PM   PM User | #2
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,046
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
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..
mlseim is offline   Reply With Quote
Old 01-22-2013, 05:39 AM   PM User | #3
HDRebel88
Regular Coder

 
Join Date: May 2011
Posts: 112
Thanks: 11
Thanked 5 Times in 5 Posts
HDRebel88 is an unknown quantity at this point
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.
HDRebel88 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:03 PM.


Advertisement
Log in to turn off these ads.