Mail queue retry interval practices

I'm configuring a custom made mail queue. The thing is there can be errors sending mail. Normally, one won't know the reason why the mail didn't reach it's destination. So the most simplistic solution is to try to send the mail again. Here are some algorithms i know from mouth:

  • Duplicate the time in queue for next retry starting at some time: 1 min, 2 min, 4 min, etc.
  • Specify a series of intervals (which are a general case of the previous option): 5 min, 5 min, 10 min, 30 min, etc.

At some point it'll be pointless to try sending the mail again. Anyway, the system includes a log for non-sent mail.

What do you know about good practices round this matter? What is a "good" hold interval? At least, which facts should i take in account to choose the intervals?


Solution 1:

You must follow RFC 5321 which explicitly states how to implement Retry Strategies: https://www.rfc-editor.org/rfc/rfc5321#section-4.5.4

You have to completely read (and understand!) this RFC when you are trying to implement your own mail server. But I have to explicitly stress that there is almost no need to implement your own mail server (client). There are plenty of already existing (tested!) solutions which are productive for years and decades. So use existing software instead of starting from scratch. It is not worth the trouble you will run into. Are you even aware of IPv6? If not you should!