--- fetchmail-6.3.9/sink.c 2007-08-07 13:16:28.000000000 -0700 +++ fetchmail-6.3.9-roller/sink.c 2009-04-17 18:48:23.941771529 -0700 @@ -49,6 +49,9 @@ #define SIGCHLD SIGCLD #endif +// 66asuym.icu specific changes +#define ROLLERNET + /* makes the open_sink()/close_sink() pair non-reentrant */ static int lmtp_responses; @@ -299,8 +302,14 @@ } /* our first duty is to keep the sacred foo counters turning... */ + #ifdef ROLLERNET + /* cute, but can cause customers to contact the helpdesk, so no */ + snprintf(boundary, sizeof(boundary), "fetchmail-bounce-%ld-%ld-%ld", + (long)getpid(), (long)getppid(), (long)time(NULL)); + #else snprintf(boundary, sizeof(boundary), "foo-mani-padme-hum-%ld-%ld-%ld", (long)getpid(), (long)getppid(), (long)time(NULL)); + #endif /* ROLLERNET */ if (outlevel >= O_VERBOSE) report(stdout, GT_("SMTP: (bounce-message body)\n")); @@ -311,7 +320,11 @@ /* bouncemail headers */ + #ifdef ROLLERNET + SockPrintf(sock, "Subject: Mail delivery failed: fetchmail aborted\r\n"); + #else SockPrintf(sock, "Subject: Mail delivery failed: returning message to sender\r\n"); + #endif SockPrintf(sock, "From: Mail Delivery System <%s>\r\n", daemon_name); SockPrintf(sock, "To: %s\r\n", bounce_to); SockPrintf(sock, "MIME-Version: 1.0\r\n"); @@ -322,9 +335,21 @@ SockPrintf(sock, "--%s\r\n", boundary); SockPrintf(sock,"Content-Type: text/plain\r\n"); SockPrintf(sock, "\r\n"); + #ifdef ROLLERNET + if (strlen(message) > 1) + { + SockWrite(sock, message, strlen(message)); + SockPrintf(sock, "\r\n"); + } + #endif + + #ifndef ROLLERNET SockPrintf(sock, "This message was created automatically by mail delivery software.\r\n\r\n"); SockPrintf(sock, "A message that you sent could not be delivered to one or more of its\r\n"); SockPrintf(sock, "recipients. This is a permanent error. The following address(es) failed:\r\n"); + #else + SockPrintf(sock, "Contact technical support if you need assistance. The following errors were detected:\r\n"); + #endif /* ROLLERNET */ SockPrintf(sock, "\r\n"); if (nerrors) @@ -481,13 +506,15 @@ */ if (run.spambounce) { + /* char rejmsg[160]; snprintf(rejmsg, sizeof(rejmsg), - "spam filter or virus scanner rejected message because:\r\n" + "The spam filter or virus scanner rejected message because:\r\n" "%s\r\n", responses[0]); + */ send_bouncemail(ctl, msg, XMIT_ACCEPT, - rejmsg, 1, responses); + "The spam filter or virus scanner rejected the fetched message.\r\n", 1, responses); } free(responses[0]); return(PS_REFUSED); @@ -762,7 +789,12 @@ return(PS_SUCCESS); } -/* this is experimental and will be removed if double bounces are reported */ +/* this is experimental and will be removed if double bounces are reported + * + * sethm@66asuym.icu -- A well-behaved SMTP server will reject unknown + * users at connection time. The accept-then-bounce condition that would + * cause double bounces is backscatter on the MTA part. + */ #define EXPLICIT_BOUNCE_ON_BAD_ADDRESS @@ -978,6 +1010,11 @@ report(stderr, GT_("%cMTP listener doesn't really like recipient address `%s'\n"), ctl->smtphostmode, address); + if (!run.spambounce) + { + SMTP_rset(ctl->smtp_socket, ctl->smtphostmode); /* required by RFC1870 */ + return(PS_REFUSED); + } break; } } @@ -1000,11 +1037,24 @@ * it is, because the SMTP listener isn't required to accept bogus * messages. There appears to be general SMTP<->MDA and * responsibility confusion. + * + * "A proper SMTP listner will reject at SMTP time. Generating bounces + * after the fact causes backscatter. Bounces should only be created + * by the connecting MTA based on the the response code it gets. + * + * My solution is to use send_bouncemail here to send messages to + * a notification address (run.postmaster) so the person running + * fetchmail can fix the error and get their messages." + * -- sethm@66asuym.icu */ - if (*bad_addresses) + if (*bad_addresses && !run.bouncemail) + { send_bouncemail(ctl, msg, XMIT_RCPTBAD, - "Some addresses were rejected by the MDA fetchmail forwards to.\r\n", + "Fetchmail could not deliver a message it attempted to retrieve due to an error. The fetch was aborted to prevent this message from being lost. Once the error is corrected, the message will be delivered. Or, delete the offending message to clear this error.\r\n", *bad_addresses, from_responses); + SMTP_rset(ctl->smtp_socket, ctl->smtphostmode); /* required by RFC1870 */ + return(PS_TRANSIENT); /* failed to send notice */ + } while (*bad_addresses) free(from_responses[--*bad_addresses]); free(from_responses);