diff options
| author | manuel <manuel@mausz.at> | 2013-02-05 18:46:26 +0100 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2013-02-05 18:46:26 +0100 |
| commit | c732bf60deb004fcb4872a639d09a7c6c9c33b73 (patch) | |
| tree | 9430f86e8a1ad524be7bcbe341f1d2c6443568b3 | |
| parent | 9fb25509df0fdd07647934c184864216566d9110 (diff) | |
| download | qmail-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.9 | 1 | ||||
| -rw-r--r-- | qmail-send.9 | 9 | ||||
| -rw-r--r-- | qmail-send.c | 37 |
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, | |||
| 178 | but it will treat any temporary delivery failures as | 178 | but it will treat any temporary delivery failures as |
| 179 | permanent failures. | 179 | permanent failures. |
| 180 | .TP 5 | 180 | .TP 5 |
| 181 | .I usebounceencap | ||
| 182 | Whether or not to encapsulate the original message in | ||
| 183 | a MIME part when sending a bounce. | ||
| 184 | Default: 0 (no). | ||
| 185 | When set to 0, the bounce contains the original | ||
| 186 | message, below the error. When set to 1, the original | ||
| 187 | message is included as a MIME message/rfc822 part, | ||
| 188 | with the error being the main text/plain part. | ||
| 189 | .TP 5 | ||
| 181 | .I virtualdomains | 190 | .I virtualdomains |
| 182 | List of virtual users or domains, one per line. | 191 | List of virtual users or domains, one per line. |
| 183 | A virtual user has the form | 192 | A 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 | ||
| 45 | int lifetime = 604800; | 45 | int lifetime = 604800; |
| 46 | int usebounceencap = 0; | ||
| 46 | 47 | ||
| 47 | int bouncemaxbytes = 50000; | 48 | int 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("ed,bouncerecip)) nomem(); | 710 | while (!quote2("ed,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\ |
| 710 | Subject: failure notice\n\ | 713 | Subject: 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\ | ||
| 712 | Hi. This is the qmail-send program at "); | 726 | Hi. 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("ed,sender.s)) nomem(); | 761 | while (!quote2("ed,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; | |||
| 1451 | int getcontrols() { if (control_init() == -1) return 0; | 1481 | int 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; |
