Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8200657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:31:34+00:00 2026-06-07T06:31:34+00:00

I want to limit sending email 90 email per hour using php code

  • 0

I want to limit sending email 90 email per hour using php code

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T06:31:37+00:00Added an answer on June 7, 2026 at 6:31 am

    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:

    $userCount = getNumberOfUsers(); // Whatever query you may have that counts how many total users there are.
    
    $numChunks = ceil($userCount/90); // How many different groups to send the email.
    
    $chunkFile = fopen('chunk_offset.txt', 'r+'); // Loads the file as resource.
    $currentChunk = fread($chunkFile, filesize('chunk_offset.txt')); // Load the contents of chunk_offset.txt into variable.
    $currentChunk = ($currentCount == '' ? 0 : (int)$currentChunk); // Load 0 if contents of file blank.
    
    $countFile = fopen('count_emails.txt', 'r+'); // Loads the file as a resource in variable $countFile.
    $currentCount = fread($countFile, filesize('count_emails.txt')); // Load the content of the file into variable $currentCount.
    $currentCount = ($currentCount == '' ? 0 : (int)$currentCount); // If the value of $currentCount is blank, then sets it to integer 0, otherwise sets the variable as the integer value of file contents.
    
    if ($currentCount <= 90) // Test the variable to see if it's under the limit. If it's under, send the email.
    {
        foreach ($whateverUserListYouHave as $integerKey => $emailAddress) // Iterating through whatever array of users you have.
        // Hopefully index number => email, but the index number is important.
        // Also, consistent ordering of the list of users is important.
        // Remember, you can always create your own counter.
        {
            // The magic:
            // You're testing for set of people who fall within the current chunk.
            if ($integerKey >= ($currentChunk * 90) && $integerKey < ($currentChunk * 90 + 90))
            {
                send_email($emailAddress); // Whatever arbitrary email function you have here.
            }
        }
    }
    
    $currentCount++; // Iterate up the count.
    fwrite($countFile, $currentCount); // Write the new count into the file.
    
    if ($currentChunk == $numChunks) // If the current chunk number hits the total number of groups of 90, then reset the file to blank...
    {
        $currentChunk = '';
    }
    else if ($currentChunk < $numChunks) // ... Otherwise iterate up and let it hit the next chunk on the next hour.
    {
        $currentChunk++; // Iterate up the chunk.
    }
    fwrite($chunkFile, $currentChunk);
    

    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:

    0 * * * * cat /dev/null > count_emails.txt
    

    The above line when added to cron, with use cat to clear the contents of the count_emails.txt file.

    Cheers, and good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to limit the calculation-speed. There was a command for rate per second.
I want to limit the character count of automatically generated page titles in php.
I'm creating a game currently and I want to limit one account per person.
I want to send hundreds of emails using PHP. To increase the execution time,
I want to ask you about sending files using WCF. I want to implement
I want to limit the text length of edit text ui element via code:
i just want limit a query by parameter inside a stored, but I get
I want to limit the size of a list in python 2.7 I have
I want to limit the use of phpsessid cookie only for secure connections during
I want to limit my SWF file so that it cannot be stolen and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.