Postfix slow email delivery
-
After setting up postfix, users are complaining that it takes too long to receive emails. It can take half a day or more after an email is sent. Why is this, and how can I fix it?
-
If you look at the postfix logs you'll see that it temporarily rejects a remote mail server's first attempt to send and replies with the message "Service currently unavailable". However, postfix saves the IP address for a period (1 day by default) and will pass the message the second time through. This is to stop spam bots, which rarely try more than once.
Postfix learns the IP addresses of (good) remote mail servers over time but many ISPs and big companies have lots and lots of servers. The emails temporarily rejected by postfix may get passed on to another mail server in the same organization and that server tries later, only to receive the same "temporarily unavailable" message because its IP address hasn't been seen before. That can happen two or three times for one email.
I recently encountered a mail server that didn't try to resend for six hours after its first attempt. That sort of misconfiguration at the sender's end can have an impact too.
To build up a longer list of mail servers that don't send to your mail server very often, you need to extend the default period for which IP addresses are cached (
which I think is seven daysalso 1 day).
Make an entry in custom main.cf options like:postscreen_cache_retention_time = 30d
Unfortunately, postfix still as to learn the IP addresses and that can take a while. It will get faster as it learns more IP addreses though.
-
…and that's why greylisting isn't very popular for people who want to treat e-mail like an IM… :-)
Most things will retry within 20-30 minutes the first time, but there are plenty of servers out there that would take longer, or would try from constantly-changing IPs.
-
Thanks for that information. And thanks for the tip. I added that custom main.cf options. I will continue testing and see if things improve.