--- conf.c Sat Apr 19 08:30:10 2003 +++ conf.c Sat Apr 19 06:53:29 2003 @@ -201,6 +201,7 @@ stringdump("postmaster", runp->postmaster); booldump("bouncemail", runp->bouncemail); booldump("spambounce", runp->spambounce); + stringdump("errmsgfile", runp->errmsgfile); stringdump("properties", runp->properties); booldump("invisible", runp->invisible); booldump("showdots", runp->showdots); --- fetchmail.c Thu Nov 8 12:33:45 2001 +++ fetchmail.c Sat Apr 19 07:35:26 2003 @@ -1643,6 +1643,8 @@ else if (outlevel >= O_VERBOSE) printf(GT_(" Spam-blocking disabled\n")); } + if (runp->errmsgfile) + printf(GT_(" Bounce messages will include %s\n"), runp->errmsgfile); if (ctl->preconnect) printf(GT_(" Server connection will be brought up with \"%s\".\n"), visbuf(ctl->preconnect)); --- fetchmail.h Fri Dec 14 01:50:01 2001 +++ fetchmail.h Sat Apr 19 06:14:34 2003 @@ -129,6 +129,7 @@ char *postmaster; flag bouncemail; flag spambounce; + char *errmsgfile; char *properties; flag use_syslog; flag invisible; --- options.c Sun Sep 30 09:30:51 2001 +++ options.c Sat Apr 19 07:22:11 2003 @@ -86,6 +86,8 @@ #define LA_SSLFINGERPRINT 60 #endif +#define LA_ERRMSGFILE 61 + /* options still left: CDgGhHjJoORwWxXYz */ static const char *shortoptions = @@ -174,6 +176,8 @@ {"tracepolls",no_argument, (int *) 0, LA_TRACEPOLLS }, + {"errmsgfile",required_argument, (int *) 0, LA_ERRMSGFILE }, + {(char *) 0, no_argument, (int *) 0, 0 } }; @@ -633,6 +637,10 @@ ctl->tracepolls = FLAG_TRUE; break; + case LA_ERRMSGFILE: + run.errmsgfile = xstrdup(optarg); + break; + case '?': case LA_HELP: default: @@ -661,6 +669,7 @@ P(GT_(" -i, --idfile specify alternate UIDs file\n")); P(GT_(" --postmaster specify recipient of last resort\n")); P(GT_(" --nobounce redirect bounces from user to postmaster.\n")); + P(GT_(" --errmsgfile text to include in bounce messages\n")); #if (defined(linux) && !INET6_ENABLE) || defined(__FreeBSD__) P(GT_(" -I, --interface interface required specification\n")); P(GT_(" -M, --monitor monitor interface for activity\n")); --- rcfile_l.l Sun Jun 24 12:51:53 2001 +++ rcfile_l.l Sat Apr 19 06:22:02 2003 @@ -69,6 +69,7 @@ postmaster { return POSTMASTER; } bouncemail { return BOUNCEMAIL; } spambounce { return SPAMBOUNCE; } +errmsgfile { return ERRMSGFILE; } warnings { return WARNINGS; } tracepolls { return TRACEPOLLS; } --- rcfile_y.y Mon Sep 24 12:49:59 2001 +++ rcfile_y.y Sat Apr 19 06:23:50 2003 @@ -66,7 +66,7 @@ %token IS HERE THERE TO MAP WILDCARD %token BATCHLIMIT FETCHLIMIT EXPUNGE PROPERTIES %token SET LOGFILE DAEMON SYSLOG IDFILE INVISIBLE POSTMASTER BOUNCEMAIL -%token SPAMBOUNCE SHOWDOTS +%token SPAMBOUNCE ERRMSGFILE SHOWDOTS %token PROTO AUTHTYPE %token STRING %token NUMBER @@ -98,6 +98,7 @@ | SET NO BOUNCEMAIL {run.bouncemail = FALSE;} | SET SPAMBOUNCE {run.spambounce = TRUE;} | SET NO SPAMBOUNCE {run.spambounce = FALSE;} + | SET ERRMSGFILE optmap STRING {run.errmsgfile = xstrdup($4);} | SET PROPERTIES optmap STRING {run.properties =xstrdup($4);} | SET SYSLOG {run.use_syslog = TRUE;} | SET NO SYSLOG {run.use_syslog = FALSE;} --- sink.c Fri Dec 14 02:51:24 2001 +++ sink.c Sat Apr 19 07:06:43 2003 @@ -201,6 +201,46 @@ *cp = '_'; } +static int insert_errmsgfile(int sock) +/* output error message (if specified and available) */ +{ + if (run.errmsgfile != NULL) + { + int len; + + if (*run.errmsgfile == '/') + { + FILE *fp; + char buf[BUFSIZ]; + + if ((fp = fopen(run.errmsgfile, "r")) != NULL) + { + while (fgets(buf, sizeof(buf), fp) != NULL) + { + len = strlen(buf); + if (len && buf[len - 1] == '\n') + len--; + SockPrintf(sock, "%.*s\r\n", len, buf); + } + (void) fclose(fp); + } + else + return (0); + } + else + { + len = strlen(run.errmsgfile); + if (len && run.errmsgfile[len - 1] == '\n') + len--; + SockPrintf(sock, "%.*s\r\n", len, run.errmsgfile); + } + + return (1); + } + + return (0); +} + static int send_bouncemail(struct query *ctl, struct msgblk *msg, int userclass, char *message, int nerrors, char *errors[]) @@ -261,6 +301,11 @@ SockWrite(sock, message, strlen(message)); SockPrintf(sock, "\r\n"); SockPrintf(sock, "\r\n"); + if (insert_errmsgfile(sock)) + { + SockPrintf(sock, "\r\n"); + SockPrintf(sock, "\r\n"); + } if (nerrors) {