I want to limit sending email 90 email per hour using php code
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use PHP to do it in this very hackish way:
Create a blank file called count_offset.txt
This will be a file that tracks the offset of the chunked set of 90 users.
Create another blank file called count_emails.txt
This will be a file that tracks the number of emails sent in the particular hour.
The PHP script that runs the email function (thru cron) can then open up this first text file to check which chunked set has been sent, and sends to the next set of users. It can check the second file for the 90 email limit.
For example:
Afterwards, write another cron that clears the count_emails.txt file every hour (or turns the contents to 0). This other cron can run another PHP script or can be a Bash command if you prefer.
Here would be the cron if you wanted to do it using Bash commands:
The above line when added to cron, with use cat to clear the contents of the count_emails.txt file.
Cheers, and good luck!