Postfix, schedule batches of email to be sent
Is it possible to have postfix limit the amount of emails it sends at once and when there is larger than x email, send them out in timed batches (wait 5 minutes, send another 50, something like that)?
I'm running into an issue where I've set my SMTP relay to be Google Apps, which limits the amount of logins per hour, due to Postfix trying to send all emails at once (a queue can burst by 1000 at a time) it times out and gives this error:
(delivery temporarily suspended: SASL authentication failed; server smtp.gmail.com[74.125.25.108] said: 454 4.7.0 Too many login attempts, please try again later. y2sm3513004pas.45 - gsmtp)
I then have to manually flush the queue about 15 times over the course of a day to send all the emails.
Solution 1:
In my earlier comment, I was wrong about transport_destination_rate_delay
behaviour.
You can set amount of delay that is inserted between individual deliveries to the same destination via transport_destination_rate_delay
The meaning of "same destination" here is
- same domain/nexthop if transport_destination_rate_delay > 1
- same recipient if transport_destination_rate_delay = 1
See this thread and this documentation page.
In your case, you have configured GApps server as relayhost
. It means postfix will see relayhost as your nexthop. So you can apply default_destination_rate_delay
to delay delivery attempt to one GApps although you have multiple domain to send.
Given you want to 50 email per 5 minutes then you can configure postfix to give (5 * 60) / 50 = 6s delay per delivery.
#main.cf
default_destination_rate_delay = 6s