Rate Limit Handling Feature¶
Overview¶
The Rate Limit Handling feature automatically detects when email services impose sending limits and pauses the mass email campaign to prevent errors and account penalties. When rate limits are encountered, the system will:
- Pause email sending for a predefined period (default: 1 hour for daily quota limits)
- Send a notification email to the sender explaining the rate limit
- Show a visual indicator in the Progress UI
- Automatically resume sending when the waiting period ends
How It Works¶
Detection¶
The system recognizes several types of rate limit errors, including:
- Gmail daily sending quota ("Exception: Service invoked too many times for one day: email") - 1 hour pause
- Gmail rate limits ("Exception: Service invoked too many times in a short time") - 15 minutes pause
- API rate limits ("User-rate limit exceeded") - 30 minutes pause
Automatic Handling¶
When a rate limit is detected:
- The current batch operation is paused
- Rate limit state is stored in the system
- A timed trigger is created to resume sending after the waiting period
- A notification email is sent to the campaign owner
- The Progress UI shows a rate limit indicator with countdown timer
User Interface¶
In the Progress UI, you'll see: - A clear yellow warning indicator when rate limited - A countdown showing when sending will resume - The standard email statistics continue to update
How to Avoid Rate Limits¶
To minimize the chance of hitting rate limits:
- Adjust batch size: Use smaller batch sizes (15-25 emails per batch)
- Increase batch intervals: Add more time between batches (5+ minutes)
- Set daily limits: Stay well below Gmail's daily sending limits
- Use proper authentication: Ensure your email is properly authenticated
- Distribute over time: Schedule large campaigns across multiple days
Technical Details¶
The system uses the following components to manage rate limits:
RateLimitHandler.js: Core logic for detecting and managing rate limits- Pattern matching to identify specific error types
- User and Script Properties to store rate limit state
- Time-based triggers for automatic resumption
- UI integration to display real-time rate limit status
Customizing Rate Limit Behavior¶
Advanced users can customize rate limit behavior by modifying the KNOWN_ERROR_PATTERNS array in RateLimitHandler.js:
const KNOWN_ERROR_PATTERNS = [
{
pattern: "Exception: Service invoked too many times for one day: email",
waitTimeMinutes: 60, // Adjust the wait time as needed
errorType: "GMAIL_DAILY_QUOTA",
message: "Gmail daily sending quota has been reached. Sending will resume after 1 hour."
},
// Add more patterns here as needed
];