Hello, I really hope I will get some answers. I have to do a PHP newsletter that will take NAME and EMAIL from 2 tables and send a predefinite number of emails per hour. So my first problem is taking the emails I know how to make the query, the thing is that the TO: where I send the email must be: Name <email>. But the NAME is different in the 2 tables, so I have to "unite them in the same variabile. On the first table I have: - Denumire - Email 1 - Email 2 On the seccond table I have: - Name - Email A friend of mine sugested to use foreach to send emails to each email. Pretty logical. But my main problem is how to only send 100 emails per HOUR? How should I approach this? Thanks.
Is there a reason we should know about as to why you don't want to use phplist? No need really to re-invent the wheel as they make it quite round.
Try PHPMailer, I have been using it for newsletters for a long time and it works great. As for the emails per hour thing, use CRON
See more here - http://en.wikipedia.org/wiki/Crontab CRON basically schedules your scripts to launch periodically at given time. So if you want to send 500 emails every hour, you write the script that sends out 500 emails and then put it into CRON table to launch every hour.
Thanx Houdas for informing abouth the CRONTAB i dont really need this right now but i think it will be very usefull in the future. Thanx again
I understand that, the thing is how do I know how on what emails have been send. For exemple: I send emails to email1, email2, email3. Next hour how do I know that I msut start from email4?
To every e-mail in your database table, you add a column "sent" - it could be a number - before the whole sending starts, you just set sent to 0, and then for every email sent, you set it to one: Quick&dirty code: $res = mysql_query("SELECT * FROM emails WHERE sent=0"); while($email = mysql_fetch_assoc($res)) { mail(....) // send the mail mysql_query("UPDATE emails SET sent=1 WHERE email=$email['email']"); } PHP:
I see your point, the thing is that my emails are on other tables, not in a "designed" table especialy for emails. EDIT: nevermind, i see your point my problem is how do I create that cron job? Never used it before, I mean...code it but I have used some cron jobs in vBulletin.