limiting the rate of emails using python
- by Ali
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.