fetchmail-friends
[Top] [All Lists]

Re: [fetchmail] exit with non zero code, 2nd

2002-09-13 04:33:16
Sunil Shetye <shetye(_at_)bombay(_dot_)retortsoft(_dot_)com> writes:

Quoting from Matthias Andree's mail on Fri, Sep 13, 2002 at 01:21:17AM +0200:
Hello, (this is the second time that I sent this message, perhaps!)
I've configured fetchmail to retrieve all message from a single
account out of the organization and to redistribuite the email
to the local accounts. It's seem to work fine but when arrived
a mail to unknown local user, sendmail end with status code not 0
end fetchmail cannot continue to delete the erroeus message.
Where i failed?

But note the man page:

:      Fetchmail's  method of sending bouncemail and spam bounces
:      requires that port 25 of localhost be available for  send-
:      ing mail via SMTP.

Let me first of all apologize for my inefficient discussion, I did not
read up on all the command line options that the original poster,
Carlo Lucetti, used, and answer that question first:

Carlo, to solve your problem for now, drop using the mda as already
suggested, and at any rate,

           remove -oem option from your mda line

that you have now.

Sunil, I appreciate your work on fetchmail and all the bounce issues,
but I beg to differ on the MDA issue.

The regular operation is: the MTA -- including fetchmail -- [1] makes
the routing decision, figures if the address is routable, and only if it
knows the user exists, switches to that user and calls upon the MDA [2].

[1] mail transport agent: fetchmail, getmail;
    sendmail, postfix, exim, courier, zmailer, qmail
[2] mail delivery agent: binmail, deliver, procmail, maildrop

For the communication between the MDA and the MTA, the <sysexits.h>
protocol is used. That is: as the MDA returns its exit status, and the
MTA treats it accordingly:

- as success if the status is zero,
- as temporary failure if the MDA caught a signal that it did not handle or
  when the exit status is EX_TEMPFAIL, trying again later and
- as permanent error, generating a bounce for any other exit status.

Don't take the CAPS below at screaming at you, I use this emphasis to
mean the same is in RFC 2119.

Fetchmail MUST adhere to this protocol if we want it to be successful
with the MDA option.

I think the mda is supposed to send the bouncemail on its own anyway.

The MDA MUST NOT send mail. Its only task is to deliver the mail it is
passed, exit 0, or fail and exit non-zero. The MTA then generates the
bounce.

sendmail does so when invoked on the command line. So, there is no
need for fetchmail to send a bouncemail separately based on the exit
code. (Else, this will lead to the Return of Double Bounce:-)

fetchmail MUST send the bounce itself, because virtually no MTA except
the original sendmail (which loses ground as it's cumbersome to
configure) supports -oem. So, for compatibility reasons, this option
cannot not be used or recommended.

So, when using the original sendmail software as MDA, the -oem and
-OErrorMode=m options MUST NOT be given. When using sendmail, the caller
MUST use either the -oep, -oeq, -OErrorMode=p or -OErrorMode=q options
instead.

Assume fetchmail generated the bounce itself: The bounce would be sent
twice if and only if sendmail was invoked with the inadequate -oem or
-OErrorMode=m command line options. These options make sendmail send a
bounce AND STILL return failure even if sending the bounce was delivered
successfully.

Again, assume fetchmail generated the bounce itself: with the -oep or
-oeq options, fetchmail would be the only instance to generate the
bounce.

Another option would be to write a shell script which hides certain
exit statuses. Attached is one such script. Make this executable.
Replace /usr/sbin/sendmail by the full path of this script file in the
mda line.

This will make error reporting unreliable and must be avoided.

So, my plan is:

1. Make fetchmail able to send bounces through /usr/sbin/sendmail.  To
   achieve this, the SMTP-sending code should be put into its own
   capsule and decoupled from regular mail routing or bouncing. We could
   also have a look at:

   - Brian Stafford's libESMTP (LGPL license)
   http://www.stafford.uklinux.net/libesmtp/ or

   - Jef Poskanzer's mini_sendmail (X11 license IIRC)
   http://www.acme.com/software/mini_sendmail/ (but I'm unsure how this
   must be adjusted).

2. Weed -oem and -OErrorMode=m options from any externally-called
   programs should the user add this option, to extinct double bounce risk.

3. Make fetchmail bounce when the MDA fails.

4. Consider if we need to rename the MDA option to MTA (as it can also
   send bounces at that future time), and add a new MDA option that only
   really works with a real MDA.

I hope to get rid of some lines of code through 1. above.

-- 
Matthias Andree