fetchmail-friends
[Top] [All Lists]

[fetchmail] [PATCH] Re: bouncing on empty return-path

2003-01-07 02:34:58
Quoting from Maarten Bezemer's mail on Mon, Jan 06, 2003 at 11:36:23PM +0100:
1) Most, if not all smtp listeners don't accept a
   MAIL FROM:<MAILER-DAEMON>

This is not going to happen. Conversion of addresses to the
appropriate format is handled later. There is no point in handling it
here.

   Even more: it would be rewritten to MAILER-DAEMON(_at_)popservername in
   open_smtp_sink() [sink.c]

Yes, that was my intention.

In fact, I have noted that when a MAIL FROM: <> is sent to the mailbox
on my popservername, the Return-Path: is stored as
<MAILER-DAEMON(_at_)popservername> and not <>! Then, when fetchmail gets
that mail, the from address is <MAILER-DAEMON(_at_)popservername>. I have
not checked who is doing this rewriting and why.

So, my opinion is that no harm is done if <> is converted to
MAILER-DAEMON (and eventually to <MAILER-DAEMON(_at_)popservername>).

2) That would still cause mail to be sent out on delivery failure, while
   exactly that was what the patch tries to prevent.

Yes, this is true. However, fetchmail should not bounce mails to
MAILER-DAEMON anyway! Here is a patch which does that:

===========================================================
diff -Naur fetchmail-6.2.0.orig/sink.c fetchmail-6.2.0/sink.c
--- fetchmail-6.2.0.orig/sink.c Mon Jan  6 10:50:36 2003
+++ fetchmail-6.2.0/sink.c      Tue Jan  7 11:06:51 2003
@@ -264,9 +264,13 @@
     char boundary[BUFSIZ], *bounce_to;
     int sock;
     static char *fqdn_of_host = NULL;
+    const char *md1 = "MAILER-DAEMON", *md2 = "MAILER-DAEMON@";
 
     /* don't bounce in reply to undeliverable bounces */
-    if (!msg->return_path[0] || strcmp(msg->return_path, "<>") == 0)
+    if (!msg->return_path[0] ||
+       strcmp(msg->return_path, "<>") == 0 ||
+       strcasecmp(msg->return_path, md1) == 0 ||
+       strncasecmp(msg->return_path, md2, strlen(md2)) == 0)
        return(FALSE);
 
     bounce_to = (run.bouncemail ? msg->return_path : run.postmaster);
===========================================================

Undoubtedly, there could be more addresses for which bounces should
not occur like "postmaster" or even "FETCHMAIL-DAEMON"! However, this
patch will atleast solve the mailing loop problem.

The only difference would be that "somedomain" would become
"popservername". Which raises another interesting question: what happens
with mail (especially the bounces) sent to 
MAILER-DAEMON(_at_)yourowndomain(_dot_)com
if fetchmail pops mail from yourowndomain.com:pop3? In that case you
don't even need two sites running fetchmail to create a mail loop :-)

In fact, this already happens if popservername is anyway converting <>
to <MAILER-DAEMON(_at_)popservername> when storing in the mailbox.

I didn't check the mda and escape stuff yet, but I do think the right way
would be to replace the "<>" to "MAILER-DAEMON" only for mda transport,
right before the escaping.

In my opinion, coding specifically for mda is not a good thing to do.

The return path address is handled slightly differently in different
places now. However, from what I can see, merging all this into one
function will not do any harm.

-- 
Sunil Shetye.