limiting the rate of emails using python
Posted
by Ali
on Stack Overflow
See other posts from Stack Overflow
or by Ali
Published on 2010-05-03T18:41:12Z
Indexed on
2010/05/03
18:48 UTC
Read the original article
Hit count: 162
I have a python script which reads email addresses from a database for a particular date, example today, and sends out an email message to them one by one. It reads data from MySQL using the MySQLdb module and stores all results in a dictionary and sends out emails using :
rows = cursor.fetchall () #All email addresses returned that are supposed to go out on todays date.
for row is rows: #send email
However, my hosting service only lets me send out 500 emails per hour. How can I limit my script from making sure only 500 emails are sent in an hour and then to check the database if more emails are left for today or not and then to send them in the next hour.
The script is activated using a cron job.
© Stack Overflow or respective owner