summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2013-02-05 18:46:26 +0100
committermanuel <manuel@mausz.at>2013-02-05 18:46:26 +0100
commitc732bf60deb004fcb4872a639d09a7c6c9c33b73 (patch)
tree9430f86e8a1ad524be7bcbe341f1d2c6443568b3
parent9fb25509df0fdd07647934c184864216566d9110 (diff)
downloadqmail-c732bf60deb004fcb4872a639d09a7c6c9c33b73.tar.gz
qmail-c732bf60deb004fcb4872a639d09a7c6c9c33b73.tar.bz2
qmail-c732bf60deb004fcb4872a639d09a7c6c9c33b73.zip
[PATCH] rfc822 bounces
Adding qmail-bounce-encap to encapsulate bounces in rfc822 messages qmail-bounce-encap-20040210
-rw-r--r--qmail-control.91
-rw-r--r--qmail-send.99
-rw-r--r--qmail-send.c37
3 files changed, 44 insertions, 3 deletions
diff --git a/qmail-control.9 b/qmail-control.9
index c9bb986..28c4ecf 100644
--- a/qmail-control.9
+++ b/qmail-control.9
@@ -85,6 +85,7 @@ control default used by
85.I tlsclientciphers \fR(none) \fRqmail-remote 85.I tlsclientciphers \fR(none) \fRqmail-remote
86.I tlshosts/FQDN.pem \fR(none) \fRqmail-remote 86.I tlshosts/FQDN.pem \fR(none) \fRqmail-remote
87.I tlsserverciphers \fR(none) \fRqmail-smtpd 87.I tlsserverciphers \fR(none) \fRqmail-smtpd
88.I usebounceencap \fR0 \fRqmail-send
88.I virtualdomains \fR(none) \fRqmail-send 89.I virtualdomains \fR(none) \fRqmail-send
89.fi 90.fi
90.RE 91.RE
diff --git a/qmail-send.9 b/qmail-send.9
index e5a44f5..e5be479 100644
--- a/qmail-send.9
+++ b/qmail-send.9
@@ -178,6 +178,15 @@ will try the message once more,
178but it will treat any temporary delivery failures as 178but it will treat any temporary delivery failures as
179permanent failures. 179permanent failures.
180.TP 5 180.TP 5
181.I usebounceencap
182Whether or not to encapsulate the original message in
183a MIME part when sending a bounce.
184Default: 0 (no).
185When set to 0, the bounce contains the original
186message, below the error. When set to 1, the original
187message is included as a MIME message/rfc822 part,
188with the error being the main text/plain part.
189.TP 5
181.I virtualdomains 190.I virtualdomains
182List of virtual users or domains, one per line. 191List of virtual users or domains, one per line.
183A virtual user has the form 192A virtual user has the form
diff --git a/qmail-send.c b/qmail-send.c
index ccdc852..685b08c 100644
--- a/qmail-send.c
+++ b/qmail-send.c
@@ -43,6 +43,7 @@
43#define OSSIFIED 129600 /* 36 hours; _must_ exceed q-q's DEATH (24 hours) */ 43#define OSSIFIED 129600 /* 36 hours; _must_ exceed q-q's DEATH (24 hours) */
44 44
45int lifetime = 604800; 45int lifetime = 604800;
46int usebounceencap = 0;
46 47
47int bouncemaxbytes = 50000; 48int bouncemaxbytes = 50000;
48 49
@@ -665,6 +666,8 @@ unsigned long id;
665 static stralloc quoted = {0}; 666 static stralloc quoted = {0};
666 datetime_sec birth; 667 datetime_sec birth;
667 unsigned long qp; 668 unsigned long qp;
669 char strid[FMT_ULONG];
670 char strqp[FMT_ULONG];
668 671
669 if (!getinfo(&sender,&birth,id)) return 0; /* XXX: print warning */ 672 if (!getinfo(&sender,&birth,id)) return 0; /* XXX: print warning */
670 673
@@ -707,8 +710,19 @@ unsigned long id;
707 while (!quote2(&quoted,bouncerecip)) nomem(); 710 while (!quote2(&quoted,bouncerecip)) nomem();
708 qmail_put(&qqt,quoted.s,quoted.len); 711 qmail_put(&qqt,quoted.s,quoted.len);
709 qmail_puts(&qqt,"\n\ 712 qmail_puts(&qqt,"\n\
710Subject: failure notice\n\ 713Subject: failure notice\n");
711\n\ 714 if(usebounceencap > 0) {
715 strid[fmt_ulong(strid,id)] = 0;
716 strqp[fmt_ulong(strqp,qp)] = 0;
717 qmail_puts(&qqt,"MIME-Version: 1.0\nContent-Type: multipart/mixed; boundary=\"qrfm-");
718 qmail_puts(&qqt,strid);
719 qmail_puts(&qqt,strqp);
720 qmail_puts(&qqt,"\"\n\nThis is a multi-part message in MIME format.\n\n--qrfm-");
721 qmail_puts(&qqt,strid);
722 qmail_puts(&qqt,strqp);
723 qmail_puts(&qqt,"\nContent-Type: text/plain\n");
724 }
725 qmail_puts(&qqt,"\n\
712Hi. This is the qmail-send program at "); 726Hi. This is the qmail-send program at ");
713 qmail_put(&qqt,bouncehost.s,bouncehost.len); 727 qmail_put(&qqt,bouncehost.s,bouncehost.len);
714 qmail_puts(&qqt,*sender.s ? ".\n\ 728 qmail_puts(&qqt,*sender.s ? ".\n\
@@ -733,7 +747,16 @@ I tried to deliver a bounce message to this address, but the bounce bounced!\n\
733 qmail_fail(&qqt); 747 qmail_fail(&qqt);
734 } 748 }
735 749
736 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"); 750 if(usebounceencap > 0) {
751 qmail_puts(&qqt,*sender.s ? "--- Attached is a copy of the message.\n\n" : "--- Attached is the original bounce.\n\n");
752 qmail_puts(&qqt,"--qrfm-");
753 qmail_puts(&qqt,strid);
754 qmail_puts(&qqt,strqp);
755 qmail_puts(&qqt,"\nContent-Type: message/rfc822\nContent-Disposition: attachment\n\n");
756 } else {
757 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");
758 }
759
737 qmail_puts(&qqt,"Return-Path: <"); 760 qmail_puts(&qqt,"Return-Path: <");
738 while (!quote2(&quoted,sender.s)) nomem(); 761 while (!quote2(&quoted,sender.s)) nomem();
739 qmail_put(&qqt,quoted.s,quoted.len); 762 qmail_put(&qqt,quoted.s,quoted.len);
@@ -760,6 +783,13 @@ I tried to deliver a bounce message to this address, but the bounce bounced!\n\
760 qmail_fail(&qqt); 783 qmail_fail(&qqt);
761 } 784 }
762 785
786 if(usebounceencap > 0) {
787 qmail_puts(&qqt,"\n--qrfm-");
788 qmail_puts(&qqt,strid);
789 qmail_puts(&qqt,strqp);
790 qmail_puts(&qqt,"--\n");
791 }
792
763 qmail_from(&qqt,bouncesender); 793 qmail_from(&qqt,bouncesender);
764 qmail_to(&qqt,bouncerecip); 794 qmail_to(&qqt,bouncerecip);
765 if (*qmail_close(&qqt)) 795 if (*qmail_close(&qqt))
@@ -1451,6 +1481,7 @@ fd_set *rfds;
1451int getcontrols() { if (control_init() == -1) return 0; 1481int getcontrols() { if (control_init() == -1) return 0;
1452 if (control_readint(&bouncemaxbytes,"control/bouncemaxbytes") == -1) return 0; 1482 if (control_readint(&bouncemaxbytes,"control/bouncemaxbytes") == -1) return 0;
1453 if (control_readint(&lifetime,"control/queuelifetime") == -1) return 0; 1483 if (control_readint(&lifetime,"control/queuelifetime") == -1) return 0;
1484 if (control_readint(&usebounceencap,"control/usebounceencap") == -1) return 0;
1454 if (control_readint(&concurrency[0],"control/concurrencylocal") == -1) return 0; 1485 if (control_readint(&concurrency[0],"control/concurrencylocal") == -1) return 0;
1455 if (control_readint(&concurrency[1],"control/concurrencyremote") == -1) return 0; 1486 if (control_readint(&concurrency[1],"control/concurrencyremote") == -1) return 0;
1456 if (control_rldef(&envnoathost,"control/envnoathost",1,"envnoathost") != 1) return 0; 1487 if (control_rldef(&envnoathost,"control/envnoathost",1,"envnoathost") != 1) return 0;