Re: How getmail deals with delivery errors and with bounce e-mails

"R. Diez" <[email protected]> Thu, 5 Nov 2020 09:21:06 +0100
Newsgroups gmane.mail.getmail.user
Message-ID <[email protected]>
> I don't know where you are looking,. but the Getmail documentation on 
> MDA_External: <http://pyropus.ca/software/getmail/configuration.html#destination-mdaexternal>
> doesn't stop there, the first example is:
 >
>      A basic invocation of an external MDA might look like this:
> 
>      [destination]
>      type = MDA_external
>      path = /path/to/mymda
>      arguments = ("--log-errors", )


There is nothing in the getmail documentation I could find about proper error handling in this case.

If you are referring to the "--log-errors" parameter in the example above, that would suggest writing to syslog or similar, which still does 
not notify you per e-mail as you said. We are back to reading or grepping syslog.

Look what other people suggest:

https://wiki.dovecot.org/HowTo/TriggerGetmailOnIMAPAccess

They suggest running /usr/lib/dovecot/deliver with -e, of which documentation states:

-e: If mail gets rejected, write the rejection reason to stderr and exit with EX_NOPERM. The default is to send a rejection mail ourself.

I think that they have overlooked error handling, because that way, they will never receive an automatic e-mail notification if delivering 
fails.

All this becomes apparent if you try to document getmail's exit status code, like all good man pages should do. Let's begin:

   EXIT STATUS

   0 on success
   something else on critical error

At which point the user will start thinking "Wait a moment, what is a critical error? Is not delivering my precious e-mail a non-critical 
error then?".

This is actually a funny irony. getmail itself had to jump through hoops because some MDAs were not reporting errors, look at the 
documentation for configuration setting ignore_stderr .

But getmail itself is doing the same. You tell it "fetch me 10 mails", and it fetches 5 and reports success.

I could write a wrapper script that looks at getmail's stderr and then assume that something failed.

That would of course break other typical usage of stderr, like outputting warnings or tracing messages for troubleshooting purposes.

One cleaner solution would be to exit with a non-zero status code if at least one delivery failed. I bet systemd has some setting to 
automatically e-mail you when a service that runs on a timer fails.


> If you don't considerer the Getmail documentation to be canonical for Getmail, well, we can't help you.

I do not understand why you keep discrediting me personally with expressions like "we can't help you". I does not look good on you either.

Regards,
   rdiez