MIME-HEADERS As people happily sends big attachments over email, the probability of failures increases. This is annoying for those of us with limited bandwidth, wasted on bounces of several MB in size. This is based on Fred Lindsberg's MIME bounce patch. It supresses the body of the message, leaving only the headers for reference. Note that if you use ezmlm, you may need Fred's patch for ezmlm-return, which is not included here. Jose Luis Painceira, jose@pccp.net.ar INSTALLATION cd /usr/src/qmail-1.03 patch < qmail-send.mime-headers.diff make kill qmail-send make setup restart qmail --- qmail-send.c Mon Jun 15 07:53:16 1998 +++ qmail-send.c Wed Oct 24 10:36:58 2001 @@ -55,6 +55,7 @@ stralloc bouncehost = {0}; stralloc doublebounceto = {0}; stralloc doublebouncehost = {0}; +stralloc boundary = {0}; char strnum2[FMT_ULONG]; char strnum3[FMT_ULONG]; @@ -661,6 +662,7 @@ static stralloc quoted = {0}; datetime_sec birth; unsigned long qp; + int endhdr, lastlf, z; if (!getinfo(&sender,&birth,id)) return 0; /* XXX: print warning */ @@ -702,9 +704,17 @@ qmail_puts(&qqt,"\nTo: "); while (!quote2("ed,bouncerecip)) nomem(); qmail_put(&qqt,quoted.s,quoted.len); - qmail_puts(&qqt,"\n\ -Subject: failure notice\n\ -\n\ + /* MIME header with boundary */ + qmail_puts(&qqt,"\nMIME-Version: 1.0\n" + "Content-Type: multipart/mixed; " + "boundary=\""); + if (!stralloc_copyb(&boundary,strnum2,fmt_ulong(strnum2,birth))) nomem(); + if (!stralloc_cat(&boundary,&bouncehost)) nomem(); + if (!stralloc_catb(&boundary,strnum2,fmt_ulong(strnum2,id))) nomem(); + qmail_put(&qqt,boundary.s,boundary.len); + qmail_puts(&qqt,"\"\nSubject: failure notice\n\n--"); + qmail_put(&qqt,boundary.s,boundary.len); /* def type is text/plain */ + qmail_puts(&qqt,"\n\n\ Hi. This is the qmail-send program at "); qmail_put(&qqt,bouncehost.s,bouncehost.len); qmail_puts(&qqt,*sender.s ? ".\n\ @@ -729,7 +739,9 @@ qmail_fail(&qqt); } - qmail_puts(&qqt,*sender.s ? "--- Below this line is a copy of the message.\n\n" : "--- Below this line is the original bounce.\n\n"); + qmail_puts(&qqt,*sender.s ? "--- Enclosed are the original headers of the message.\n\n--" : "--- Enclosed is the original bounce.\n\n--"); + qmail_put(&qqt,boundary.s,boundary.len); /* enclosure boundary */ + qmail_puts(&qqt,"\nContent-Type: message/rfc822\n\n"); qmail_puts(&qqt,"Return-Path: <"); while (!quote2("ed,sender.s)) nomem(); qmail_put(&qqt,quoted.s,quoted.len); @@ -741,12 +753,30 @@ else { substdio_fdbuf(&ssread,read,fd,inbuf,sizeof(inbuf)); - while ((r = substdio_get(&ssread,buf,sizeof(buf))) > 0) + + endhdr = 0; lastlf = 0; + while((r = substdio_get(&ssread,buf,sizeof(buf))) && (!endhdr)) { + if(lastlf && (*buf == '\n')) /* case \n\n spanned across two get() */ + break; + for(z=0; z