]> git.ipfire.org Git - thirdparty/postfix.git/commitdiff
postfix-3.7-20211002
authorWietse Venema <wietse@porcupine.org>
Sat, 2 Oct 2021 05:00:00 +0000 (00:00 -0500)
committerViktor Dukhovni <postfix-users@dukhovni.org>
Wed, 19 Jan 2022 06:36:07 +0000 (01:36 -0500)
54 files changed:
postfix/HISTORY
postfix/html/bounce.8.html
postfix/html/cleanup.8.html
postfix/html/defer.8.html
postfix/html/lmtp.8.html
postfix/html/smtp.8.html
postfix/html/smtpd.8.html
postfix/html/trace.8.html
postfix/man/man8/bounce.8
postfix/man/man8/cleanup.8
postfix/man/man8/smtp.8
postfix/man/man8/smtpd.8
postfix/src/bounce/2template_test.in
postfix/src/bounce/Makefile.in
postfix/src/bounce/bounce.c
postfix/src/bounce/bounce_notify_util_tester.c
postfix/src/bounce/bounce_service.h
postfix/src/bounce/bounce_template.c
postfix/src/bounce/bounce_template.h
postfix/src/bounce/bounce_templates.c
postfix/src/bounce/no-msgid-no-eoh-event-no-thread.ref
postfix/src/bounce/no-msgid-no-eoh-event-with-thread.ref
postfix/src/bounce/no-msgid-with-eoh-event-no-thread.ref
postfix/src/bounce/no-msgid-with-eoh-event-with-thread.ref
postfix/src/bounce/obs_template_test.ref [new file with mode: 0644]
postfix/src/bounce/template_test.ref
postfix/src/bounce/with-msgid-no-eoh-event-no-thread.ref
postfix/src/bounce/with-msgid-no-eoh-event-with-thread.ref
postfix/src/bounce/with-msgid-with-eoh-event-no-thread.ref
postfix/src/bounce/with-msgid-with-eoh-event-with-thread.ref
postfix/src/bounce/with-msgid-with-filter-no-thread.ref
postfix/src/bounce/with-msgid-with-filter-with-thread.ref
postfix/src/bounce/with-msgid-with-long-line-no-thread.ref
postfix/src/bounce/with-msgid-with-long-line-with-thread.ref
postfix/src/cleanup/Makefile.in
postfix/src/cleanup/cleanup.c
postfix/src/cleanup/cleanup.h
postfix/src/cleanup/cleanup_init.c
postfix/src/cleanup/cleanup_message.c
postfix/src/global/Makefile.in
postfix/src/global/hfrom_format.c [new file with mode: 0644]
postfix/src/global/hfrom_format.h [new file with mode: 0644]
postfix/src/global/hfrom_format.ref [new file with mode: 0644]
postfix/src/global/mail_version.h
postfix/src/smtp/Makefile.in
postfix/src/smtp/lmtp_params.c
postfix/src/smtp/smtp.c
postfix/src/smtp/smtp.h
postfix/src/smtp/smtp_chat.c
postfix/src/smtp/smtp_params.c
postfix/src/smtpd/Makefile.in
postfix/src/smtpd/smtpd.c
postfix/src/smtpd/smtpd.h
postfix/src/smtpd/smtpd_chat.c

index a77b594c9eaefa61e35e6cde25d177ff3c34637d..0485b328c45eeee0c07c9373cdec61ef35f81966 100644 (file)
@@ -25780,3 +25780,18 @@ Apologies for any names omitted.
 
        Cleanup: don't hyperlink text that is already hyperlinked.
        File: mantools/postlink.
+
+20211002
+
+       Bugfix (introduced: Postfix 3.3): the header_from_format
+       feature was not implemented for From: headers from the
+       bounce daemon, and for Postfix SMTP server and client
+       postmaster notifications.  Reported by Vladimir Mishonov.
+       Files: bounce/bounce.c, bounce/bounce_notify_util_tester.c,
+       bounce/bounce_service.h, bounce/bounce_template.c,
+       bounce/bounce_template.h, bounce/bounce_templates.c,
+       cleanup/cleanup.h, cleanup/cleanup_init.c,
+       cleanup/cleanup_message.c, smtp/lmtp_params.c, smtp/smtp.c,
+       smtp/smtp.h, smtp/smtp_chat.c, smtp/smtp_params.c,
+       smtpd/smtpd.c, smtpd/smtpd.h, smtpd/smtpd_chat.c, and test
+       data.
index d5caebb1cbd4cb0e1750fecae819e7cb66f17519..077af166889e81b230f81f82bb21b5f2b199dd13 100644 (file)
@@ -160,6 +160,11 @@ BOUNCE(8)                                                            BOUNCE(8)
               to   the   original  message  by  including  a  References:  and
               In-Reply-To: header with the original Message-ID value.
 
+       Available in Postfix 3.7 and later:
+
+       <b>header_from_format (standard)</b>
+              The format of the Postfix-generated <b>From:</b> header.
+
 <b>FILES</b>
        /var/spool/postfix/bounce/* non-delivery records
        /var/spool/postfix/defer/* non-delivery records
index 38c0f2baaaab1770990a6afd32c3ffcdb21e461d..c276f6cbffbbd4309212ea32abb8b347583fafca 100644 (file)
@@ -117,6 +117,9 @@ CLEANUP(8)                                                          CLEANUP(8)
               after  applying  <a href="header_checks.5.html"><b>header_checks</b>(5)</a>  and  before  invoking  Milter
               applications.
 
+       <b>header_from_format (standard)</b>
+              The format of the Postfix-generated <b>From:</b> header.
+
 <b>BUILT-IN CONTENT FILTERING CONTROLS</b>
        Postfix built-in content filtering is meant to stop a flood of worms or
        viruses. It is not a general content filter.
index d5caebb1cbd4cb0e1750fecae819e7cb66f17519..077af166889e81b230f81f82bb21b5f2b199dd13 100644 (file)
@@ -160,6 +160,11 @@ BOUNCE(8)                                                            BOUNCE(8)
               to   the   original  message  by  including  a  References:  and
               In-Reply-To: header with the original Message-ID value.
 
+       Available in Postfix 3.7 and later:
+
+       <b>header_from_format (standard)</b>
+              The format of the Postfix-generated <b>From:</b> header.
+
 <b>FILES</b>
        /var/spool/postfix/bounce/* non-delivery records
        /var/spool/postfix/defer/* non-delivery records
index 2f654e0a633de87ea943c9046f86b918dcb4526d..b4420f221cdfc24e9ffdd94795167348ed5557e5 100644 (file)
@@ -392,6 +392,9 @@ SMTP(8)                                                                SMTP(8)
               DATA    requests,    when    deadlines    are    enabled    with
               <a href="postconf.5.html#smtp_per_request_deadline">smtp_per_request_deadline</a>.
 
+       <b>header_from_format (standard)</b>
+              The format of the Postfix-generated <b>From:</b> header.
+
 <b>MIME PROCESSING CONTROLS</b>
        Available in Postfix version 2.0 and later:
 
index 2f654e0a633de87ea943c9046f86b918dcb4526d..b4420f221cdfc24e9ffdd94795167348ed5557e5 100644 (file)
@@ -392,6 +392,9 @@ SMTP(8)                                                                SMTP(8)
               DATA    requests,    when    deadlines    are    enabled    with
               <a href="postconf.5.html#smtp_per_request_deadline">smtp_per_request_deadline</a>.
 
+       <b>header_from_format (standard)</b>
+              The format of the Postfix-generated <b>From:</b> header.
+
 <b>MIME PROCESSING CONTROLS</b>
        Available in Postfix version 2.0 and later:
 
index 8d8f6dc6fc5d76ebd2097c05655528103b66deb5..db7d76308b2d7142e65cbdc621656f113ba1299c 100644 (file)
@@ -951,6 +951,9 @@ SMTPD(8)                                                              SMTPD(8)
               DATA   and  BDAT  requests,  when  deadlines  are  enabled  with
               <a href="postconf.5.html#smtpd_per_request_deadline">smtpd_per_request_deadline</a>.
 
+       <b>header_from_format (standard)</b>
+              The format of the Postfix-generated <b>From:</b> header.
+
 <b>TARPIT CONTROLS</b>
        When a remote SMTP client makes errors, the  Postfix  SMTP  server  can
        insert  delays  before  responding. This can help to slow down run-away
index d5caebb1cbd4cb0e1750fecae819e7cb66f17519..077af166889e81b230f81f82bb21b5f2b199dd13 100644 (file)
@@ -160,6 +160,11 @@ BOUNCE(8)                                                            BOUNCE(8)
               to   the   original  message  by  including  a  References:  and
               In-Reply-To: header with the original Message-ID value.
 
+       Available in Postfix 3.7 and later:
+
+       <b>header_from_format (standard)</b>
+              The format of the Postfix-generated <b>From:</b> header.
+
 <b>FILES</b>
        /var/spool/postfix/bounce/* non-delivery records
        /var/spool/postfix/defer/* non-delivery records
index 1c51978872deb0e8a2484bbccebe20c0356d261d..007ffdc0d6307869c4d70f61401829c8d1f4dbaf 100644 (file)
@@ -142,6 +142,10 @@ Available in Postfix 3.6 and later:
 Enable non\-delivery, success, and delay notifications that link
 to the original message by including a References: and In\-Reply\-To:
 header with the original Message\-ID value.
+.PP
+Available in Postfix 3.7 and later:
+.IP "\fBheader_from_format (standard)\fR"
+The format of the Postfix\-generated \fBFrom:\fR header.
 .SH "FILES"
 .na
 .nf
index 8c07ecac507ee2ce7fd480397224cbdd50c311b5..8c2cc0b9e70341d856169a814049c7847b982a62 100644 (file)
@@ -130,6 +130,8 @@ Available in Postfix version 3.0 and later:
 .IP "\fBmessage_drop_headers (bcc, content\-length, resent\-bcc, return\-path)\fR"
 Names of message headers that the \fBcleanup\fR(8) daemon will remove
 after applying \fBheader_checks\fR(5) and before invoking Milter applications.
+.IP "\fBheader_from_format (standard)\fR"
+The format of the Postfix\-generated \fBFrom:\fR header.
 .SH "BUILT-IN CONTENT FILTERING CONTROLS"
 .na
 .nf
index 656c6eed87336f80dfc8936566dc51e0cefe2aaf..add4aec34a4fc366d46f447ceee0680f27ad8a6b 100644 (file)
@@ -376,6 +376,8 @@ complete SMTP response.
 .IP "\fBsmtp_min_data_rate (500)\fR"
 The minimum plaintext data transfer rate in bytes/second for
 DATA requests, when deadlines are enabled with smtp_per_request_deadline.
+.IP "\fBheader_from_format (standard)\fR"
+The format of the Postfix\-generated \fBFrom:\fR header.
 .SH "MIME PROCESSING CONTROLS"
 .na
 .nf
index ea910ae06c5e732273d4b0da16509faa5dff6b5d..44b050327b90a03108a83295b023ff917821f574 100644 (file)
@@ -834,6 +834,8 @@ and for sending a complete SMTP response.
 The minimum plaintext data transfer rate in bytes/second for
 DATA and BDAT requests, when deadlines are enabled with
 smtpd_per_request_deadline.
+.IP "\fBheader_from_format (standard)\fR"
+The format of the Postfix\-generated \fBFrom:\fR header.
 .SH "TARPIT CONTROLS"
 .na
 .nf
index 8afb4cef9cbd480cbe843eb4a4a78cf6f5ab9ac9..e45fd3266343809d97583ffd50a116a4d1c45776 100644 (file)
@@ -1,6 +1,6 @@
 failure_template = <<EOF
 Charset: us-ascii
-From: MAILER-DAEMON (Mail Delivery System)
+From: Mail Delivery System <MAILER-DAEMON>
 Subject: Undelivered Mail Returned to Sender
 Postmaster-Subject: Postmaster Copy: Undelivered Mail
 
@@ -19,7 +19,7 @@ EOF
 
 delay_template = <<EOF
 Charset: us-ascii
-From: MAILER-DAEMON (Mail Delivery System)
+From: Mail Delivery System <MAILER-DAEMON>
 Subject: Delayed Mail (still being retried)
 Postmaster-Subject: Postmaster Warning: Delayed Mail
 
@@ -42,7 +42,7 @@ EOF
 
 success_template = <<EOF
 Charset: us-ascii
-From: MAILER-DAEMON (Mail Delivery System)
+From: Mail Delivery System <MAILER-DAEMON>
 Subject: Successful Mail Delivery Report
 
 This is the mail system at host $myhostname.
@@ -57,7 +57,7 @@ EOF
 
 verify_template = <<EOF
 Charset: us-ascii
-From: MAILER-DAEMON (Mail Delivery System)
+From: Mail Delivery System <MAILER-DAEMON>
 Subject: Mail Delivery Status Report
 
 This is the mail system at host $myhostname.
@@ -68,7 +68,7 @@ Enclosed is the mail delivery report that you requested.
 EOF
 failure_template = <<EOF
 Charset: us-ascii
-From: MAILER-DAEMON (Mail Delivery System)
+From: Mail Delivery System <MAILER-DAEMON>
 Subject: Undelivered Mail Returned to Sender
 Postmaster-Subject: Postmaster Copy: Undelivered Mail
 
@@ -87,7 +87,7 @@ EOF
 
 delay_template = <<EOF
 Charset: us-ascii
-From: MAILER-DAEMON (Mail Delivery System)
+From: Mail Delivery System <MAILER-DAEMON>
 Subject: Delayed Mail (still being retried)
 Postmaster-Subject: Postmaster Warning: Delayed Mail
 
@@ -110,7 +110,7 @@ EOF
 
 success_template = <<EOF
 Charset: us-ascii
-From: MAILER-DAEMON (Mail Delivery System)
+From: Mail Delivery System <MAILER-DAEMON>
 Subject: Successful Mail Delivery Report
 
 This is the mail system at host $myhostname.
@@ -125,7 +125,7 @@ EOF
 
 verify_template = <<EOF
 Charset: us-ascii
-From: MAILER-DAEMON (Mail Delivery System)
+From: Mail Delivery System <MAILER-DAEMON>
 Subject: Mail Delivery Status Report
 
 This is the mail system at host $myhostname.
index cd5ed85fd7367fd0cea2cf0c242b0b55a6e2d372..969413a0003d993be817c7e76ff8f9d8c059cf98 100644 (file)
@@ -38,7 +38,7 @@ Makefile: Makefile.in
 
 test:  $(TESTPROG)
 
-tests: update template_test 2template_test \
+tests: update template_test obs_template_test 2template_test \
        with-msgid-with-long-line_test \
        with-msgid-with-eoh-event_test \
        with-msgid-no-eoh-event_test \
@@ -82,6 +82,7 @@ bounce_notify_util_tester: $(BOUNCE_NOTIFY_UTIL_TESTER_OBJS) $(LIBS)
 template_test: $(PROG) template_test.ref
        echo queue_directory=. >main.cf
        echo myhostname=example.com >>main.cf
+       echo header_from_format=standard >>main.cf
        touch -t 197101010000 main.cf
        MAIL_CONFIG=. ./$(PROG) -SVzndump_templates >template_test.tmp
        diff template_test.ref template_test.tmp
@@ -90,6 +91,15 @@ template_test: $(PROG) template_test.ref
        diff template_test.ref template_test.tmp
        rm -f template_test.tmp main.cf
 
+obs_template_test: $(PROG) obs_template_test.ref
+       echo queue_directory=. >main.cf
+       echo myhostname=example.com >>main.cf
+       echo header_from_format=obsolete >>main.cf
+       touch -t 197101010000 main.cf
+       MAIL_CONFIG=. ./$(PROG) -SVzndump_templates >template_test.tmp
+       diff obs_template_test.ref template_test.tmp
+       rm -f template_test.tmp main.cf
+
 2template_test: $(PROG) template_test.ref 2template_test.in
        echo queue_directory=. >main.cf
        echo myhostname=example.com >>main.cf
@@ -327,6 +337,7 @@ bounce.o: ../../include/deliver_request.h
 bounce.o: ../../include/dsb_scan.h
 bounce.o: ../../include/dsn.h
 bounce.o: ../../include/dsn_buf.h
+bounce.o: ../../include/hfrom_format.h
 bounce.o: ../../include/htable.h
 bounce.o: ../../include/iostuff.h
 bounce.o: ../../include/load_file.h
@@ -481,6 +492,7 @@ bounce_notify_util_tester.o: ../../include/check_arg.h
 bounce_notify_util_tester.o: ../../include/dsn.h
 bounce_notify_util_tester.o: ../../include/dsn_buf.h
 bounce_notify_util_tester.o: ../../include/dsn_mask.h
+bounce_notify_util_tester.o: ../../include/hfrom_format.h
 bounce_notify_util_tester.o: ../../include/htable.h
 bounce_notify_util_tester.o: ../../include/mail_conf.h
 bounce_notify_util_tester.o: ../../include/mail_params.h
@@ -570,7 +582,11 @@ bounce_one_service.o: bounce_one_service.c
 bounce_one_service.o: bounce_service.h
 bounce_one_service.o: bounce_template.h
 bounce_template.o: ../../include/attr.h
+bounce_template.o: ../../include/bounce_log.h
 bounce_template.o: ../../include/check_arg.h
+bounce_template.o: ../../include/dsn.h
+bounce_template.o: ../../include/dsn_buf.h
+bounce_template.o: ../../include/hfrom_format.h
 bounce_template.o: ../../include/htable.h
 bounce_template.o: ../../include/iostuff.h
 bounce_template.o: ../../include/is_header.h
@@ -583,12 +599,15 @@ bounce_template.o: ../../include/midna_domain.h
 bounce_template.o: ../../include/msg.h
 bounce_template.o: ../../include/mymalloc.h
 bounce_template.o: ../../include/nvtable.h
+bounce_template.o: ../../include/rcpt_buf.h
+bounce_template.o: ../../include/recipient_list.h
 bounce_template.o: ../../include/split_at.h
 bounce_template.o: ../../include/stringops.h
 bounce_template.o: ../../include/sys_defs.h
 bounce_template.o: ../../include/vbuf.h
 bounce_template.o: ../../include/vstream.h
 bounce_template.o: ../../include/vstring.h
+bounce_template.o: bounce_service.h
 bounce_template.o: bounce_template.c
 bounce_template.o: bounce_template.h
 bounce_templates.o: ../../include/attr.h
index 6f6643e17e5db05559132c90372ffca6e48f8ce8..23939299b957aca7a1edd0fb9d6969be73d3ed16 100644 (file)
 /*     Enable non-delivery, success, and delay notifications that link
 /*     to the original message by including a References: and In-Reply-To:
 /*     header with the original Message-ID value.
+/* .PP
+/*     Available in Postfix 3.7 and later:
+/* .IP "\fBheader_from_format (standard)\fR"
+/*     The format of the Postfix-generated \fBFrom:\fR header.
 /* FILES
 /*     /var/spool/postfix/bounce/* non-delivery records
 /*     /var/spool/postfix/defer/* non-delivery records
 #include <mail_addr.h>
 #include <rcpt_buf.h>
 #include <dsb_scan.h>
+#include <hfrom_format.h>
 
 /* Single-threaded server skeleton. */
 
@@ -204,6 +209,7 @@ char   *var_2bounce_rcpt;
 char   *var_delay_rcpt;
 char   *var_bounce_tmpl;
 bool    var_threaded_bounce;
+char   *var_hfrom_format;              /* header_from_format */
 
  /*
   * We're single threaded, so we can avoid some memory allocation overhead.
@@ -222,6 +228,11 @@ static DSN_BUF *dsn_buf;
   */
 BOUNCE_TEMPLATES *bounce_templates;
 
+ /*
+  * From: header format.
+  */
+int     bounce_hfrom_format;
+
 #define STR vstring_str
 
 #define VS_NEUTER(s) printable(vstring_str(s), '?')
@@ -620,6 +631,7 @@ static void pre_jail_init(char *unused_name, char **unused_argv)
 
 static void post_jail_init(char *service_name, char **unused_argv)
 {
+    bounce_hfrom_format = hfrom_format_parse(VAR_HFROM_FORMAT, var_hfrom_format);
 
     /*
      * Special case: dump bounce templates. This is not part of the master(5)
@@ -673,6 +685,7 @@ int     main(int argc, char **argv)
        VAR_2BOUNCE_RCPT, DEF_2BOUNCE_RCPT, &var_2bounce_rcpt, 1, 0,
        VAR_DELAY_RCPT, DEF_DELAY_RCPT, &var_delay_rcpt, 1, 0,
        VAR_BOUNCE_TMPL, DEF_BOUNCE_TMPL, &var_bounce_tmpl, 0, 0,
+       VAR_HFROM_FORMAT, DEF_HFROM_FORMAT, &var_hfrom_format, 1, 0,
        0,
     };
     static const CONFIG_NBOOL_TABLE nbool_table[] = {
index b8abdd730e5852748c576462efeb87e09c561887..da13f470579903312bb5b0de654e8d5332a72cc8 100644 (file)
@@ -19,6 +19,7 @@
 #include <mail_params.h>
 #include <record.h>
 #include <rec_type.h>
+#include <hfrom_format.h>
 
  /*
   * Bounce service.
@@ -59,6 +60,9 @@ static void test_driver(int argc, char **argv)
     if (chdir(var_queue_dir) < 0)
        msg_fatal("chdir %s: %m", var_queue_dir);
 
+    bounce_hfrom_format = 
+       hfrom_format_parse(VAR_HFROM_FORMAT, var_hfrom_format);
+
     /*
      * Write one message to VSTRING.
      */
@@ -123,6 +127,9 @@ char   *var_2bounce_rcpt;
 char   *var_delay_rcpt;
 char   *var_bounce_tmpl;
 bool    var_threaded_bounce;
+char   *var_hfrom_format;              /* header_from_format */
+
+int     bounce_hfrom_format;
 
 int     main(int argc, char **argv)
 {
@@ -141,6 +148,7 @@ int     main(int argc, char **argv)
        VAR_2BOUNCE_RCPT, DEF_2BOUNCE_RCPT, &var_2bounce_rcpt, 1, 0,
        VAR_DELAY_RCPT, DEF_DELAY_RCPT, &var_delay_rcpt, 1, 0,
        VAR_BOUNCE_TMPL, DEF_BOUNCE_TMPL, &var_bounce_tmpl, 0, 0,
+       VAR_HFROM_FORMAT, DEF_HFROM_FORMAT, &var_hfrom_format, 1, 0,
        0,
     };
     static const CONFIG_NBOOL_TABLE nbool_table[] = {
index 40793f2ff1ff49aabda140f8957e6cca2d030149..b79542fc9e5450dd5cf90e87687664395dd9bf4e 100644 (file)
   */
 #include <bounce_template.h>
 
+ /*
+  * bounce_service.c
+  */
+extern int bounce_hfrom_format;
+
  /*
   * bounce_append_service.c
   */
index 629f83bfeac120f418fca079b7f187d9f58ae437..67a5cf7c6d62ddeff0434cad562ec559d1d892bc 100644 (file)
 #include <mail_proto.h>
 #include <mail_conf.h>
 #include <is_header.h>
+#include <hfrom_format.h>
 
 /* Application-specific. */
 
 #include <bounce_template.h>
+#include <bounce_service.h>
 
  /*
   * The following tables implement support for bounce template expansions of
@@ -334,7 +336,7 @@ static void bounce_template_parse_buffer(BOUNCE_TEMPLATE *tp)
        if (strcasecmp("charset", cp) == 0) {
            tp->mime_charset = hval;
        } else if (strcasecmp("from", cp) == 0) {
-           tp->from = hval;
+           tp->std_from = tp->obs_from = hval;
        } else if (strcasecmp("subject", cp) == 0) {
            tp->subject = hval;
        } else if (strcasecmp("postmaster-subject", cp) == 0) {
@@ -491,7 +493,8 @@ void    bounce_template_headers(BOUNCE_XP_PRN_FN out_fn, VSTREAM *fp,
     if (tp->flags & BOUNCE_TMPL_FLAG_NEW_BUFFER)
        bounce_template_parse_buffer(tp);
 
-    out_fn(fp, "From: %s", tp->from);
+    out_fn(fp, "From: %s", bounce_hfrom_format == HFROM_FORMAT_CODE_STD ?
+          tp->std_from : tp->obs_from);
     out_fn(fp, "Subject: %s", tp->postmaster_subject && postmaster_copy ?
           tp->postmaster_subject : tp->subject);
     out_fn(fp, "To: %s", rcpt);
@@ -533,7 +536,8 @@ void    bounce_template_dump(VSTREAM *fp, BOUNCE_TEMPLATE *tp)
        bounce_template_parse_buffer(tp);
 
     vstream_fprintf(fp, "Charset: %s\n", tp->mime_charset);
-    vstream_fprintf(fp, "From: %s\n", tp->from);
+    vstream_fprintf(fp, "From: %s\n", bounce_hfrom_format == HFROM_FORMAT_CODE_STD ?
+                   tp->std_from : tp->obs_from);
     vstream_fprintf(fp, "Subject: %s\n", tp->subject);
     if (tp->postmaster_subject)
        vstream_fprintf(fp, "Postmaster-Subject: %s\n",
index 5b771e466e446503fb1fcd3eba8569f055ab7616..87835fcbe481272060b6f14298a821a9049b8fac 100644 (file)
@@ -27,7 +27,8 @@ typedef struct BOUNCE_TEMPLATE {
     const char *origin;                        /* built-in or pathname */
     const char *mime_charset;          /* character set (configurable) */
     const char *mime_encoding;         /* 7bit or 8bit (derived) */
-    const char *from;                  /* originator (configurable) */
+    const char *obs_from;              /* originator (configurable) */
+    const char *std_from;              /* originator (configurable) */
     const char *subject;               /* general subject (configurable) */
     const char *postmaster_subject;    /* postmaster subject (configurable) */
     const char **message_text;         /* message text (configurable) */
index 11daece4165ec7c61991a613a68d5040be9a0a67..f81dfd4dd045957a5775170de51beb9261c6b7dc 100644 (file)
 /*     IBM T.J. Watson Research
 /*     P.O. Box 704
 /*     Yorktown Heights, NY 10598, USA
+/*
+/*     Wietse Venema
+/*     Google, Inc.
+/*     111 8th Avenue
+/*     New York, NY 10011, USA
 /*--*/
 
 /* System library. */
@@ -114,6 +119,7 @@ static const BOUNCE_TEMPLATE def_bounce_failure_template = {
     "us-ascii",
     MAIL_ATTR_ENC_7BIT,
     MAIL_ADDR_MAIL_DAEMON " (Mail Delivery System)",
+    "Mail Delivery System <" MAIL_ADDR_MAIL_DAEMON ">",
     "Undelivered Mail Returned to Sender",
     "Postmaster Copy: Undelivered Mail",
     def_bounce_failure_body,
@@ -130,8 +136,7 @@ static const char *def_bounce_delay_body[] = {
     "# THIS IS A WARNING ONLY.  YOU DO NOT NEED TO RESEND YOUR MESSAGE. #",
     "####################################################################",
     "",
-    "Your message could not be delivered for more than $delay_warning_time_hours hour(s)."
-    ,
+    "Your message could not be delivered for more than $delay_warning_time_hours hour(s).",
     "It will be retried until it is $maximal_queue_lifetime_days day(s) old.",
     "",
     "For further assistance, please send mail to " MAIL_ADDR_POSTMASTER ".",
@@ -150,6 +155,7 @@ static const BOUNCE_TEMPLATE def_bounce_delay_template = {
     "us-ascii",
     MAIL_ATTR_ENC_7BIT,
     MAIL_ADDR_MAIL_DAEMON " (Mail Delivery System)",
+    "Mail Delivery System <" MAIL_ADDR_MAIL_DAEMON ">",
     "Delayed Mail (still being retried)",
     "Postmaster Warning: Delayed Mail",
     def_bounce_delay_body,
@@ -179,6 +185,7 @@ static const BOUNCE_TEMPLATE def_bounce_success_template = {
     "us-ascii",
     MAIL_ATTR_ENC_7BIT,
     MAIL_ADDR_MAIL_DAEMON " (Mail Delivery System)",
+    "Mail Delivery System <" MAIL_ADDR_MAIL_DAEMON ">",
     "Successful Mail Delivery Report",
     0,
     def_bounce_success_body,
@@ -205,6 +212,7 @@ static const BOUNCE_TEMPLATE def_bounce_verify_template = {
     "us-ascii",
     MAIL_ATTR_ENC_7BIT,
     MAIL_ADDR_MAIL_DAEMON " (Mail Delivery System)",
+    "Mail Delivery System <" MAIL_ADDR_MAIL_DAEMON ">",
     "Mail Delivery Status Report",
     0,
     def_bounce_verify_body,
index 0ec87a9aa1810d4f93b64c9c207465b6dfc7154a..630734d2ec7960ecdda9869186b64dbe1c683891 100644 (file)
@@ -1,4 +1,4 @@
-From: MAILER-DAEMON (Mail Delivery System)
+From: Mail Delivery System <MAILER-DAEMON>
 Subject: Undelivered Mail Returned to Sender
 To: test-recipient
 Auto-Submitted: auto-replied
index 0ec87a9aa1810d4f93b64c9c207465b6dfc7154a..630734d2ec7960ecdda9869186b64dbe1c683891 100644 (file)
@@ -1,4 +1,4 @@
-From: MAILER-DAEMON (Mail Delivery System)
+From: Mail Delivery System <MAILER-DAEMON>
 Subject: Undelivered Mail Returned to Sender
 To: test-recipient
 Auto-Submitted: auto-replied
index 8741e085fe7537c0559b80e685df7333444b9d94..39b5841d295506f5224c9574901dabe123192e06 100644 (file)
@@ -1,4 +1,4 @@
-From: MAILER-DAEMON (Mail Delivery System)
+From: Mail Delivery System <MAILER-DAEMON>
 Subject: Undelivered Mail Returned to Sender
 To: test-recipient
 Auto-Submitted: auto-replied
index 8741e085fe7537c0559b80e685df7333444b9d94..39b5841d295506f5224c9574901dabe123192e06 100644 (file)
@@ -1,4 +1,4 @@
-From: MAILER-DAEMON (Mail Delivery System)
+From: Mail Delivery System <MAILER-DAEMON>
 Subject: Undelivered Mail Returned to Sender
 To: test-recipient
 Auto-Submitted: auto-replied
diff --git a/postfix/src/bounce/obs_template_test.ref b/postfix/src/bounce/obs_template_test.ref
new file mode 100644 (file)
index 0000000..e03bb5b
--- /dev/null
@@ -0,0 +1,68 @@
+failure_template = <<EOF
+Charset: us-ascii
+From: MAILER-DAEMON (Mail Delivery System)
+Subject: Undelivered Mail Returned to Sender
+Postmaster-Subject: Postmaster Copy: Undelivered Mail
+
+This is the mail system at host $myhostname.
+
+I'm sorry to have to inform you that your message could not
+be delivered to one or more recipients. It's attached below.
+
+For further assistance, please send mail to postmaster.
+
+If you do so, please include this problem report. You can
+delete your own text from the attached returned message.
+
+                   The mail system
+EOF
+
+delay_template = <<EOF
+Charset: us-ascii
+From: MAILER-DAEMON (Mail Delivery System)
+Subject: Delayed Mail (still being retried)
+Postmaster-Subject: Postmaster Warning: Delayed Mail
+
+This is the mail system at host $myhostname.
+
+####################################################################
+# THIS IS A WARNING ONLY.  YOU DO NOT NEED TO RESEND YOUR MESSAGE. #
+####################################################################
+
+Your message could not be delivered for more than $delay_warning_time_hours hour(s).
+It will be retried until it is $maximal_queue_lifetime_days day(s) old.
+
+For further assistance, please send mail to postmaster.
+
+If you do so, please include this problem report. You can
+delete your own text from the attached returned message.
+
+                   The mail system
+EOF
+
+success_template = <<EOF
+Charset: us-ascii
+From: MAILER-DAEMON (Mail Delivery System)
+Subject: Successful Mail Delivery Report
+
+This is the mail system at host $myhostname.
+
+Your message was successfully delivered to the destination(s)
+listed below. If the message was delivered to mailbox you will
+receive no further notifications. Otherwise you may still receive
+notifications of mail delivery errors from other systems.
+
+                   The mail system
+EOF
+
+verify_template = <<EOF
+Charset: us-ascii
+From: MAILER-DAEMON (Mail Delivery System)
+Subject: Mail Delivery Status Report
+
+This is the mail system at host $myhostname.
+
+Enclosed is the mail delivery report that you requested.
+
+                   The mail system
+EOF
index e03bb5b8b46f0a8267cc519831070b076f25603d..381c14dcad6a220e2f8a2c72195c9954eab5c44d 100644 (file)
@@ -1,6 +1,6 @@
 failure_template = <<EOF
 Charset: us-ascii
-From: MAILER-DAEMON (Mail Delivery System)
+From: Mail Delivery System <MAILER-DAEMON>
 Subject: Undelivered Mail Returned to Sender
 Postmaster-Subject: Postmaster Copy: Undelivered Mail
 
@@ -19,7 +19,7 @@ EOF
 
 delay_template = <<EOF
 Charset: us-ascii
-From: MAILER-DAEMON (Mail Delivery System)
+From: Mail Delivery System <MAILER-DAEMON>
 Subject: Delayed Mail (still being retried)
 Postmaster-Subject: Postmaster Warning: Delayed Mail
 
@@ -42,7 +42,7 @@ EOF
 
 success_template = <<EOF
 Charset: us-ascii
-From: MAILER-DAEMON (Mail Delivery System)
+From: Mail Delivery System <MAILER-DAEMON>
 Subject: Successful Mail Delivery Report
 
 This is the mail system at host $myhostname.
@@ -57,7 +57,7 @@ EOF
 
 verify_template = <<EOF
 Charset: us-ascii
-From: MAILER-DAEMON (Mail Delivery System)
+From: Mail Delivery System <MAILER-DAEMON>
 Subject: Mail Delivery Status Report
 
 This is the mail system at host $myhostname.
index 3798b6f16f8fee2d788134825657086c57c72fe5..020d9a4c1d2f4b644cc3d3e742a269e8e68401fc 100644 (file)
@@ -1,4 +1,4 @@
-From: MAILER-DAEMON (Mail Delivery System)
+From: Mail Delivery System <MAILER-DAEMON>
 Subject: Undelivered Mail Returned to Sender
 To: test-recipient
 Auto-Submitted: auto-replied
index 30ee63a40ffa3070a0530daa5fcf8b3c98ec476d..d2aadd08883815d3cdb5979a69c1748a0fd832c5 100644 (file)
@@ -1,4 +1,4 @@
-From: MAILER-DAEMON (Mail Delivery System)
+From: Mail Delivery System <MAILER-DAEMON>
 Subject: Undelivered Mail Returned to Sender
 To: test-recipient
 References: <12345@mta-name.example>
index 67bc27d1ee0adfa0bca825346bbaa66f1a2d8af7..70afb5f333aadb1488e8f1ba66a29d089f5eaff7 100644 (file)
@@ -1,4 +1,4 @@
-From: MAILER-DAEMON (Mail Delivery System)
+From: Mail Delivery System <MAILER-DAEMON>
 Subject: Undelivered Mail Returned to Sender
 To: test-recipient
 Auto-Submitted: auto-replied
index eb1e126fdd517dd423fdb7f0a4519505d881caaa..e46afbe9fe7c87c07de230a9ee24c6014552ccd0 100644 (file)
@@ -1,4 +1,4 @@
-From: MAILER-DAEMON (Mail Delivery System)
+From: Mail Delivery System <MAILER-DAEMON>
 Subject: Undelivered Mail Returned to Sender
 To: test-recipient
 References: <12345@mta-name.example>
index 0666540af2e10de7ac7741b169776b932cd04beb..fa30ddfdb9958096c1bd79d26c73e30fb70beb52 100644 (file)
@@ -1,4 +1,4 @@
-From: MAILER-DAEMON (Mail Delivery System)
+From: Mail Delivery System <MAILER-DAEMON>
 Subject: Undelivered Mail Returned to Sender
 To: test-recipient
 Auto-Submitted: auto-replied
index 520c3b832d5bda2329043fb185e6a6c487caadf8..14d33730d0b61f74daf78a12a2c9d875a360f480 100644 (file)
@@ -1,4 +1,4 @@
-From: MAILER-DAEMON (Mail Delivery System)
+From: Mail Delivery System <MAILER-DAEMON>
 Subject: Undelivered Mail Returned to Sender
 To: test-recipient
 References: <12345@mta-name.example>
index b26a05250fe852d032e1a3fa32aed08e611e716d..fa5268bb8bab0ff1662fc622b5dd500871164f80 100644 (file)
@@ -1,4 +1,4 @@
-From: MAILER-DAEMON (Mail Delivery System)
+From: Mail Delivery System <MAILER-DAEMON>
 Subject: Undelivered Mail Returned to Sender
 To: test-recipient
 Auto-Submitted: auto-replied
index c22838ad2e1a1e15fff0877ebf7b63fd1cfc2042..04e96d68cc0f068c4406868d065b8d9462b6e679 100644 (file)
@@ -1,4 +1,4 @@
-From: MAILER-DAEMON (Mail Delivery System)
+From: Mail Delivery System <MAILER-DAEMON>
 Subject: Undelivered Mail Returned to Sender
 To: test-recipient
 References: <12345@mta-name.example>
index 2b8f11917acea03f4ca44042237ca8aee68c5291..8a3c18c956ca5d6184bfafd744d4fc6a7e0cf988 100644 (file)
@@ -996,6 +996,7 @@ cleanup_init.o: ../../include/ext_prop.h
 cleanup_init.o: ../../include/flush_clnt.h
 cleanup_init.o: ../../include/header_body_checks.h
 cleanup_init.o: ../../include/header_opts.h
+cleanup_init.o: ../../include/hfrom_format.h
 cleanup_init.o: ../../include/htable.h
 cleanup_init.o: ../../include/iostuff.h
 cleanup_init.o: ../../include/mail_addr.h
@@ -1137,6 +1138,7 @@ cleanup_message.o: ../../include/dsn_util.h
 cleanup_message.o: ../../include/ext_prop.h
 cleanup_message.o: ../../include/header_body_checks.h
 cleanup_message.o: ../../include/header_opts.h
+cleanup_message.o: ../../include/hfrom_format.h
 cleanup_message.o: ../../include/htable.h
 cleanup_message.o: ../../include/info_log_addr_form.h
 cleanup_message.o: ../../include/iostuff.h
index 6ebe1b0add9ca89336eed8dbdd01c9602948319c..73cc03d57257ddf71bec20cf559b6b71644d01eb 100644 (file)
 /* .IP "\fBmessage_drop_headers (bcc, content-length, resent-bcc, return-path)\fR"
 /*     Names of message headers that the \fBcleanup\fR(8) daemon will remove
 /*     after applying \fBheader_checks\fR(5) and before invoking Milter applications.
+/* .IP "\fBheader_from_format (standard)\fR"
+/*     The format of the Postfix-generated \fBFrom:\fR header.
 /* BUILT-IN CONTENT FILTERING CONTROLS
 /* .ad
 /* .fi
index 50fe6ebd02d8487626f6f41c01a5dd319b83154c..43de26f373bbc305c9e143995d5a8ccf243be842 100644 (file)
@@ -352,9 +352,7 @@ extern void cleanup_body_edit_free(CLEANUP_STATE *);
  /*
   * From: header formatting.
   */
-#define HFROM_FORMAT_CODE_STD  0
-#define HFROM_FORMAT_CODE_OBS  1
-extern int hfrom_format_code;
+extern int cleanup_hfrom_format;
 
 /* LICENSE
 /* .ad
index d0af954774eabb6f823e7b1e6ea6a298cfd5496e..9ae72860720ef37b01e7013da5b898e9650a081c 100644 (file)
 #include <mail_version.h>              /* milter_macro_v */
 #include <ext_prop.h>
 #include <flush_clnt.h>
+#include <hfrom_format.h>
 
 /* Application-specific. */
 
@@ -282,7 +283,7 @@ MILTERS *cleanup_milters;
  /*
   * From: header format.
   */
-int     hfrom_format_code;
+int     cleanup_hfrom_format;
 
 /* cleanup_all - callback for the runtime error handler */
 
@@ -434,11 +435,6 @@ void    cleanup_pre_jail(char *unused_name, char **unused_argv)
 
 void    cleanup_post_jail(char *unused_name, char **unused_argv)
 {
-    static const NAME_CODE hfrom_format_table[] = {
-       HFROM_FORMAT_NAME_STD, HFROM_FORMAT_CODE_STD,
-       HFROM_FORMAT_NAME_OBS, HFROM_FORMAT_CODE_OBS,
-       0, -1,
-    };
 
     /*
      * Optionally set the file size resource limit. XXX This limits the
@@ -472,8 +468,5 @@ void    cleanup_post_jail(char *unused_name, char **unused_argv)
     /*
      * From: header formatting.
      */
-    if ((hfrom_format_code = name_code(hfrom_format_table,
-                               NAME_CODE_FLAG_NONE, var_hfrom_format)) < 0)
-       msg_fatal("invalid setting: %s = %s",
-                 VAR_HFROM_FORMAT, var_hfrom_format);
+    cleanup_hfrom_format = hfrom_format_parse(VAR_HFROM_FORMAT, var_hfrom_format);
 }
index 902642f19382eaaa2bb4aef7f3bf699ade905d58..8fc0153fe7777a04eb46b3cf50673d3abcb4cbae 100644 (file)
@@ -89,6 +89,7 @@
 #include <dsn_util.h>
 #include <conv_time.h>
 #include <info_log_addr_form.h>
+#include <hfrom_format.h>
 
 /* Application-specific. */
 
@@ -760,13 +761,11 @@ static void cleanup_header_done_callback(void *context)
                   || (cp = strchr(state->fullname, '\n')) != 0)
                *cp = ' ';
 
-           switch (hfrom_format_code) {
-
-               /*
-                * "From: phrase <route-addr>". Quote the phrase if it
-                * contains specials or the "%!" legacy address operators.
-                */
-           case HFROM_FORMAT_CODE_STD:
+           /*
+            * "From: phrase <route-addr>". Quote the phrase if it contains
+            * specials or the "%!" legacy address operators.
+            */
+           if (cleanup_hfrom_format == HFROM_FORMAT_CODE_STD) {
                vstring_sprintf(state->temp2, "%sFrom: ", state->resent);
                if (state->fullname[strcspn(state->fullname,
                                            "%!" LEX_822_SPECIALS)] == 0) {
@@ -783,22 +782,18 @@ static void cleanup_header_done_callback(void *context)
                }
                vstring_sprintf_append(state->temp2, "<%s>",
                                       vstring_str(state->temp1));
-               break;
+           }
 
-               /*
-                * "From: addr-spec (ctext)". This is the obsolete form.
-                */
-           case HFROM_FORMAT_CODE_OBS:
+           /*
+            * "From: addr-spec (ctext)". This is the obsolete form.
+            */
+           else {
                vstring_sprintf(state->temp2, "%sFrom: %s ",
                                state->resent, vstring_str(state->temp1));
                vstring_sprintf(state->temp1, "(%s)", state->fullname);
                token = tok822_parse(vstring_str(state->temp1));
                tok822_externalize(state->temp2, token, TOK822_STR_NONE);
                tok822_free_tree(token);
-               break;
-           default:
-               msg_panic("%s: unknown header format %d",
-                         myname, hfrom_format_code);
            }
        }
 
index fc5244175f0e2970423cc1214d6304c99f1cada0..fb426057abe3363e0aac1311f67a09972a6d6bb6 100644 (file)
@@ -37,7 +37,8 @@ SRCS  = abounce.c anvil_clnt.c been_here.c bounce.c bounce_log.c \
        mail_addr_form.c quote_flags.c maillog_client.c \
        normalize_mailhost_addr.c map_search.c reject_deliver_request.c \
        info_log_addr_form.c sasl_mech_filter.c login_sender_match.c \
-       test_main.c compat_level.c config_known_tcp_ports.c
+       test_main.c compat_level.c config_known_tcp_ports.c \
+       hfrom_format.c
 OBJS   = abounce.o anvil_clnt.o been_here.o bounce.o bounce_log.o \
        canon_addr.o cfg_parser.o cleanup_strerror.o cleanup_strflags.o \
        clnt_stream.o conv_time.o db_common.o debug_peer.o debug_process.o \
@@ -76,7 +77,8 @@ OBJS  = abounce.o anvil_clnt.o been_here.o bounce.o bounce_log.o \
        $(NON_PLUGIN_MAP_OBJ) mail_addr_form.o quote_flags.o maillog_client.o \
        normalize_mailhost_addr.o map_search.o reject_deliver_request.o \
        info_log_addr_form.o sasl_mech_filter.o login_sender_match.o \
-       test_main.o compat_level.o config_known_tcp_ports.o
+       test_main.o compat_level.o config_known_tcp_ports.o \
+       hfrom_format.o
 # MAP_OBJ is for maps that may be dynamically loaded with dynamicmaps.cf.
 # When hard-linking these maps, makedefs sets NON_PLUGIN_MAP_OBJ=$(MAP_OBJ),
 # otherwise it sets the PLUGIN_* macros.
@@ -112,7 +114,8 @@ HDRS        = abounce.h anvil_clnt.h been_here.h bounce.h bounce_log.h \
        attr_override.h mail_parm_split.h midna_adomain.h mail_addr_form.h \
        maillog_client.h normalize_mailhost_addr.h map_search.h \
        info_log_addr_form.h sasl_mech_filter.h login_sender_match.h \
-       test_main.h compat_level.h config_known_tcp_ports.h
+       test_main.h compat_level.h config_known_tcp_ports.h \
+       hfrom_format.h
 TESTSRC        = rec2stream.c stream2rec.c recdump.c
 DEFS   = -I. -I$(INC_DIR) -D$(SYSTYPE)
 CFLAGS = $(DEBUG) $(OPT) $(DEFS)
@@ -129,7 +132,7 @@ TESTPROG= domain_list dot_lockfile mail_addr_crunch mail_addr_find \
        mail_version mail_dict server_acl uxtext mail_parm_split \
        fold_addr smtp_reply_footer mail_addr_map normalize_mailhost_addr \
        haproxy_srvr map_search delivered_hdr login_sender_match \
-       compat_level config_known_tcp_ports
+       compat_level config_known_tcp_ports hfrom_format
 
 LIBS   = ../../lib/lib$(LIB_PREFIX)util$(LIB_SUFFIX)
 LIB_DIR        = ../../lib
@@ -406,6 +409,9 @@ login_sender_match: login_sender_match.c $(LIB) $(LIBS)
 compat_level: compat_level.c $(LIB) $(LIBS)
        $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
 
+hfrom_format: hfrom_format.c $(LIB) $(LIBS)
+       $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
+
 config_known_tcp_ports: config_known_tcp_ports.c $(LIB) $(LIBS)
        $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
 
@@ -418,7 +424,7 @@ tests: tok822_test mime_tests strip_addr_test tok822_limit_test \
        mail_addr_find_test mail_addr_map_test quote_822_local_test \
        normalize_mailhost_addr_test haproxy_srvr_test map_search_test \
        delivered_hdr_test login_sender_match_test compat_level_test \
-       config_known_tcp_ports_test
+       config_known_tcp_ports_test hfrom_format_test
 
 mime_tests: mime_test mime_nest mime_8bit mime_dom mime_trunc mime_cvt \
        mime_cvt2 mime_cvt3 mime_garb1 mime_garb2 mime_garb3 mime_garb4
@@ -777,6 +783,13 @@ config_known_tcp_ports_test: update config_known_tcp_ports \
        diff config_known_tcp_ports.ref config_known_tcp_ports.tmp
        rm -f config_known_tcp_ports.tmp
 
+hfrom_format_test: update hfrom_format \
+           hfrom_format.ref
+       -$(SHLIB_ENV) $(VALGRIND) ./hfrom_format \
+            >hfrom_format.tmp 2>&1
+       diff hfrom_format.ref hfrom_format.tmp
+       rm -f hfrom_format.tmp
+
 printfck: $(OBJS) $(PROG)
        rm -rf printfck
        mkdir printfck
@@ -1520,6 +1533,12 @@ header_token.o: ../../include/vstring.h
 header_token.o: header_token.c
 header_token.o: header_token.h
 header_token.o: lex_822.h
+hfrom_format.o: ../../include/msg.h
+hfrom_format.o: ../../include/name_code.h
+hfrom_format.o: ../../include/sys_defs.h
+hfrom_format.o: hfrom_format.c
+hfrom_format.o: hfrom_format.h
+hfrom_format.o: mail_params.h
 info_log_addr_form.o: ../../include/check_arg.h
 info_log_addr_form.o: ../../include/msg.h
 info_log_addr_form.o: ../../include/name_code.h
diff --git a/postfix/src/global/hfrom_format.c b/postfix/src/global/hfrom_format.c
new file mode 100644 (file)
index 0000000..f0f850a
--- /dev/null
@@ -0,0 +1,281 @@
+/*++
+/* NAME
+/*     hfrom_format 3
+/* SUMMARY
+/*     Parse a header_from_format setting
+/* SYNOPSIS
+/*     #include <hfrom_format.h>
+/*
+/*     int     hfrom_format_parse(
+/*     const char *name,
+/*     const char *value)
+/*
+/*     const char *str_hfrom_format_code(int code)
+/* DESCRIPTION
+/*     hfrom_format_parse() takes a parameter name (used for
+/*     diagnostics) and value, and maps it to the corresponding
+/*     code: HFROM_FORMAT_NAME_STD maps to HFROM_FORMAT_CODE_STD,
+/*     and HFROM_FORMAT_NAME_OBS maps to HFROM_FORMAT_CODE_OBS.
+/*
+/*     str_hfrom_format_code() does the reverse mapping.
+/* DIAGNOSTICS
+/*     All input errors are fatal.
+/* LICENSE
+/* .ad
+/* .fi
+/*     The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/*     Wietse Venema
+/*     Google, Inc.
+/*     111 8th Avenue
+/*     New York, NY 10011, USA
+/*--*/
+
+ /*
+  * System library.
+  */
+#include <sys_defs.h>
+
+ /*
+  * Utility library.
+  */
+#include <name_code.h>
+#include <msg.h>
+
+ /*
+  * Global library.
+  */
+#include <mail_params.h>
+
+ /*
+  * Application-specific.
+  */
+#include <hfrom_format.h>
+
+ /*
+  * Primitive dependency injection.
+  */
+#ifdef TEST
+extern NORETURN PRINTFLIKE(1, 2) test_msg_fatal(const char *,...);
+
+#define msg_fatal test_msg_fatal
+#endif
+
+ /*
+  * The name-to-code mapping.
+  */
+static const NAME_CODE hfrom_format_table[] = {
+    HFROM_FORMAT_NAME_STD, HFROM_FORMAT_CODE_STD,
+    HFROM_FORMAT_NAME_OBS, HFROM_FORMAT_CODE_OBS,
+    0, -1,
+};
+
+/* hfrom_format_parse - parse header_from_format setting */
+
+int     hfrom_format_parse(const char *name, const char *value)
+{
+    int     code;
+
+    if ((code = name_code(hfrom_format_table, NAME_CODE_FLAG_NONE, value)) < 0)
+       msg_fatal("invalid setting: \"%s = %s\"", name, value);
+    return (code);
+}
+
+/* str_hfrom_format_code - convert code to string */
+
+const char *str_hfrom_format_code(int code)
+{
+    const char *name;
+
+    if ((name = str_name_code(hfrom_format_table, code)) == 0)
+       msg_fatal("invalid header format code: %d", code);
+    return (name);
+}
+
+#ifdef TEST
+#include <stdlib.h>
+#include <setjmp.h>
+#include <string.h>
+
+#include <vstream.h>
+#include <vstring.h>
+#include <msg_vstream.h>
+
+#define STR(x) vstring_str(x)
+
+ /*
+  * TODO(wietse) make this a proper VSTREAM interface. Instead of temporarily
+  * swapping streams, we could temporarily swap the stream's write function.
+  */
+
+/* vstream_swap - kludge to capture output for testing */
+
+static void vstream_swap(VSTREAM *one, VSTREAM *two)
+{
+    VSTREAM save;
+
+    save = *one;
+    *one = *two;
+    *two = save;
+}
+
+jmp_buf test_fatal_jbuf;
+
+#undef msg_fatal
+
+/* test_msg_fatal - does not return, and does not terminate */
+
+void    test_msg_fatal(const char *fmt,...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    vmsg_warn(fmt, ap);
+    va_end(ap);
+    longjmp(test_fatal_jbuf, 1);
+}
+
+struct name_test_case {
+    const char *label;                 /* identifies test case */
+    const char *config;                        /* configuration under test */
+    const char *exp_warning;           /* expected warning or empty */
+    const int exp_code;                        /* expected code */
+};
+
+static struct name_test_case name_test_cases[] = {
+    {"hfrom_format_parse good-standard",
+        /* config */ HFROM_FORMAT_NAME_STD,
+        /* warning */ "",
+        /* exp_code */ HFROM_FORMAT_CODE_STD
+    },
+    {"hfrom_format_parse good-obsolete",
+        /* config */ HFROM_FORMAT_NAME_OBS,
+        /* warning */ "",
+        /* exp_code */ HFROM_FORMAT_CODE_OBS
+    },
+    {"hfrom_format_parse bad",
+        /* config */ "does-not-exist",
+        /* warning */ "hfrom_format: warning: invalid setting: \"hfrom_format_parse bad = does-not-exist\"\n",
+        /* code */ 0,
+    },
+    {"hfrom_format_parse empty",
+        /* config */ "",
+        /* warning */ "hfrom_format: warning: invalid setting: \"hfrom_format_parse empty = \"\n",
+        /* code */ 0,
+    },
+    0,
+};
+
+struct code_test_case {
+    const char *label;                 /* identifies test case */
+    int     code;                      /* code under test */
+    const char *exp_warning;           /* expected warning or empty */
+    const char *exp_name;              /* expected namme */
+};
+
+static struct code_test_case code_test_cases[] = {
+    {"str_hfrom_format_code good-standard",
+        /* code */ HFROM_FORMAT_CODE_STD,
+        /* warning */ "",
+        /* exp_name */ HFROM_FORMAT_NAME_STD
+    },
+    {"str_hfrom_format_code good-obsolete",
+        /* code */ HFROM_FORMAT_CODE_OBS,
+        /* warning */ "",
+        /* exp_name */ HFROM_FORMAT_NAME_OBS
+    },
+    {"str_hfrom_format_code bad",
+        /* config */ 12345,
+        /* warning */ "hfrom_format: warning: invalid header format code: 12345\n",
+        /* exp_name */ 0
+    },
+    0,
+};
+
+int     main(int argc, char **argv)
+{
+    struct name_test_case *np;
+    int     code;
+    struct code_test_case *cp;
+    const char *name;
+    int     pass = 0;
+    int     fail = 0;
+    int     test_failed;
+    VSTRING *msg_buf;
+    VSTREAM *memory_stream;
+
+    msg_vstream_init("hfrom_format", VSTREAM_ERR);
+    msg_buf = vstring_alloc(100);
+
+    for (np = name_test_cases; np->label != 0; np++) {
+       VSTRING_RESET(msg_buf);
+       VSTRING_TERMINATE(msg_buf);
+       test_failed = 0;
+       if ((memory_stream = vstream_memopen(msg_buf, O_WRONLY)) == 0)
+           msg_fatal("open memory stream: %m");
+       vstream_swap(VSTREAM_ERR, memory_stream);
+       if (setjmp(test_fatal_jbuf) == 0)
+           code = hfrom_format_parse(np->label, np->config);
+       vstream_swap(memory_stream, VSTREAM_ERR);
+       if (vstream_fclose(memory_stream))
+           msg_fatal("close memory stream: %m");
+       if (strcmp(STR(msg_buf), np->exp_warning) != 0) {
+           msg_warn("test case %s: got error: \"%s\", want: \"%s\"",
+                    np->label, STR(msg_buf), np->exp_warning);
+           test_failed = 1;
+       }
+       if (*np->exp_warning == 0) {
+           if (code != np->exp_code) {
+               msg_warn("test case %s: got code: \"%d\", want: \"%d\"(%s)",
+                        np->label, code, np->exp_code,
+                        str_hfrom_format_code(np->exp_code));
+               test_failed = 1;
+           }
+       }
+       if (test_failed) {
+           msg_info("%s: FAIL", np->label);
+           fail++;
+       } else {
+           msg_info("%s: PASS", np->label);
+           pass++;
+       }
+    }
+
+    for (cp = code_test_cases; cp->label != 0; cp++) {
+       VSTRING_RESET(msg_buf);
+       VSTRING_TERMINATE(msg_buf);
+       test_failed = 0;
+       if ((memory_stream = vstream_memopen(msg_buf, O_WRONLY)) == 0)
+           msg_fatal("open memory stream: %m");
+       vstream_swap(VSTREAM_ERR, memory_stream);
+       if (setjmp(test_fatal_jbuf) == 0)
+           name = str_hfrom_format_code(cp->code);
+       vstream_swap(memory_stream, VSTREAM_ERR);
+       if (vstream_fclose(memory_stream))
+           msg_fatal("close memory stream: %m");
+       if (strcmp(STR(msg_buf), cp->exp_warning) != 0) {
+           msg_warn("test case %s: got error: \"%s\", want: \"%s\"",
+                    cp->label, STR(msg_buf), cp->exp_warning);
+           test_failed = 1;
+       } else if (*cp->exp_warning == 0) {
+           if (strcmp(name, cp->exp_name)) {
+               msg_warn("test case %s: got name: \"%s\", want: \"%s\"",
+                        cp->label, name, cp->exp_name);
+               test_failed = 1;
+           }
+       }
+       if (test_failed) {
+           msg_info("%s: FAIL", cp->label);
+           fail++;
+       } else {
+           msg_info("%s: PASS", cp->label);
+           pass++;
+       }
+    }
+
+    msg_info("PASS=%d FAIL=%d", pass, fail);
+    vstring_free(msg_buf);
+    exit(fail != 0);
+}
+
+#endif
diff --git a/postfix/src/global/hfrom_format.h b/postfix/src/global/hfrom_format.h
new file mode 100644 (file)
index 0000000..98d3ddd
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef _HFROM_FORMAT_INCLUDED_
+#define _HFROM_FORMAT_INCLUDED_
+
+/*++
+/* NAME
+/*     hfrom_format 3h
+/* SUMMARY
+/*     Parse a header_from_format setting
+/* SYNOPSIS
+/*     #include <hfrom_format.h>
+/* DESCRIPTION
+/* .nf
+
+ /*
+  * External interface.
+  */
+#define HFROM_FORMAT_CODE_OBS  0       /* Obsolete */
+#define HFROM_FORMAT_CODE_STD  1       /* Standard */
+
+extern int hfrom_format_parse(const char *, const char *);
+extern const char *str_hfrom_format_code(int);
+
+/* LICENSE
+/* .ad
+/* .fi
+/*     The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/*     Wietse Venema
+/*     Google, Inc.
+/*     111 8th Avenue
+/*     New York, NY 10011, USA
+/*--*/
+
+#endif
diff --git a/postfix/src/global/hfrom_format.ref b/postfix/src/global/hfrom_format.ref
new file mode 100644 (file)
index 0000000..28ba870
--- /dev/null
@@ -0,0 +1,8 @@
+hfrom_format: hfrom_format_parse good-standard: PASS
+hfrom_format: hfrom_format_parse good-obsolete: PASS
+hfrom_format: hfrom_format_parse bad: PASS
+hfrom_format: hfrom_format_parse empty: PASS
+hfrom_format: str_hfrom_format_code good-standard: PASS
+hfrom_format: str_hfrom_format_code good-obsolete: PASS
+hfrom_format: str_hfrom_format_code bad: PASS
+hfrom_format: PASS=7 FAIL=0
index c85f9e648c98848d222eb3f48ea49c627322f408..5649b58d88e0b113f2cd8e23e74986257be46862 100644 (file)
@@ -20,7 +20,7 @@
   * Patches change both the patchlevel and the release date. Snapshots have no
   * patchlevel; they change the release date only.
   */
-#define MAIL_RELEASE_DATE      "20210926"
+#define MAIL_RELEASE_DATE      "20211002"
 #define MAIL_VERSION_NUMBER    "3.7"
 
 #ifdef SNAPSHOT
index 2d0982af37043440d3701b7c60544f97b63ab5f5..65f41982f64cb52ff6305970f7952c4c2a32ef13 100644 (file)
@@ -103,6 +103,7 @@ smtp.o: ../../include/flush_clnt.h
 smtp.o: ../../include/fold_addr.h
 smtp.o: ../../include/header_body_checks.h
 smtp.o: ../../include/header_opts.h
+smtp.o: ../../include/hfrom_format.h
 smtp.o: ../../include/htable.h
 smtp.o: ../../include/iostuff.h
 smtp.o: ../../include/mail_conf.h
@@ -194,6 +195,7 @@ smtp_chat.o: ../../include/dsn_buf.h
 smtp_chat.o: ../../include/dsn_util.h
 smtp_chat.o: ../../include/header_body_checks.h
 smtp_chat.o: ../../include/header_opts.h
+smtp_chat.o: ../../include/hfrom_format.h
 smtp_chat.o: ../../include/htable.h
 smtp_chat.o: ../../include/int_filt.h
 smtp_chat.o: ../../include/iostuff.h
index 192d1bd21c99fdb7537e3e12b39f2ce01c258b71..d4ddfdb652bbf3579ba96a8a2cd329dc81bd17bf 100644 (file)
@@ -64,6 +64,7 @@
        VAR_LMTP_DSN_FILTER, DEF_LMTP_DSN_FILTER, &var_smtp_dsn_filter, 0, 0,
        VAR_LMTP_DNS_RE_FILTER, DEF_LMTP_DNS_RE_FILTER, &var_smtp_dns_re_filter, 0, 0,
        VAR_TLSPROXY_SERVICE, DEF_TLSPROXY_SERVICE, &var_tlsproxy_service, 1, 0,
+       VAR_HFROM_FORMAT, DEF_HFROM_FORMAT, &var_hfrom_format, 1, 0,
        0,
     };
     static const CONFIG_TIME_TABLE lmtp_time_table[] = {
        VAR_LMTP_BALANCE_INET_PROTO, DEF_LMTP_BALANCE_INET_PROTO, &var_smtp_balance_inet_proto,
        0,
     };
-   static const CONFIG_NBOOL_TABLE lmtp_nbool_table[] = {
+    static const CONFIG_NBOOL_TABLE lmtp_nbool_table[] = {
        VAR_LMTP_REQ_DEADLINE, DEF_LMTP_REQ_DEADLINE, &var_smtp_req_deadline,
        0,
-   };
+    };
index c5088798c6705fb4360085b3bb68522a80888c0e..60c8fe95e90fc3fa6adca44869984cc2bfe1e5fd 100644 (file)
 /* .IP "\fBsmtp_min_data_rate (500)\fR"
 /*     The minimum plaintext data transfer rate in bytes/second for
 /*     DATA requests, when deadlines are enabled with smtp_per_request_deadline.
+/* .IP "\fBheader_from_format (standard)\fR"
+/*     The format of the Postfix-generated \fBFrom:\fR header.
 /* MIME PROCESSING CONTROLS
 /* .ad
 /* .fi
 #include <string_list.h>
 #include <maps.h>
 #include <ext_prop.h>
+#include <hfrom_format.h>
 
 /* DNS library. */
 
@@ -1083,6 +1086,8 @@ char   *var_smtp_sasl_auth_cache_name;
 int     var_smtp_sasl_auth_cache_time;
 bool    var_smtp_sasl_auth_soft_bounce;
 
+char   *var_hfrom_format;
+
  /*
   * Global variables.
   */
@@ -1099,6 +1104,7 @@ MAPS   *smtp_pix_bug_maps;
 HBC_CHECKS *smtp_header_checks;                /* limited header checks */
 HBC_CHECKS *smtp_body_checks;          /* limited body checks */
 SMTP_CLI_ATTR smtp_cli_attr;           /* parsed command-line */
+int     smtp_hfrom_format;             /* postmaster notifications */
 
 #ifdef USE_TLS
 
@@ -1384,6 +1390,11 @@ static void post_init(char *unused_name, char **argv)
      * the process lifetime.
      */
     get_cli_attr(&smtp_cli_attr, argv);
+
+    /*
+     * header_from format, for postmaster notifications.
+     */
+    smtp_hfrom_format = hfrom_format_parse(VAR_HFROM_FORMAT, var_hfrom_format);
 }
 
 /* pre_init - pre-jail initialization */
@@ -1618,7 +1629,7 @@ int     main(int argc, char **argv)
                       CA_MAIL_SERVER_BOOL_TABLE(smtp_mode ?
                                         smtp_bool_table : lmtp_bool_table),
                       CA_MAIL_SERVER_NBOOL_TABLE(smtp_mode ?
-                                        smtp_nbool_table : lmtp_nbool_table),
+                                      smtp_nbool_table : lmtp_nbool_table),
                       CA_MAIL_SERVER_PRE_INIT(pre_init),
                       CA_MAIL_SERVER_POST_INIT(post_init),
                       CA_MAIL_SERVER_PRE_ACCEPT(pre_accept),
index e8c994fbf002ba860d3d49733bdb8b0c8905cece..07b3b3a81d67467be1c5a5a61c1d3473b531310a 100644 (file)
@@ -731,6 +731,11 @@ extern void smtp_rewrite_generic_internal(VSTRING *, const char *);
 extern void smtp_quote_822_address_flags(VSTRING *, const char *, int);
 extern void smtp_quote_821_address(VSTRING *, const char *);
 
+ /*
+  * header_from_format support, for postmaster notifications.
+  */
+extern int smtp_hfrom_format;
+
 /* LICENSE
 /* .ad
 /* .fi
index bff5986ed769723477fedd2f83735e09f3a3dc7f..81c63e478a25d18cd69b9f1f507c2a1e5c47f506 100644 (file)
 #include <post_mail.h>
 #include <mail_error.h>
 #include <dsn_util.h>
+#include <hfrom_format.h>
 
 /* Application-specific. */
 
@@ -474,9 +475,15 @@ void    smtp_chat_notify(SMTP_SESSION *session)
        msg_warn("postmaster notify: %m");
        return;
     }
-    post_mail_fprintf(notice, "From: %s (Mail Delivery System)",
-                     mail_addr_mail_daemon());
-    post_mail_fprintf(notice, "To: %s (Postmaster)", var_error_rcpt);
+    if (smtp_hfrom_format == HFROM_FORMAT_CODE_STD) {
+       post_mail_fprintf(notice, "From: Mail Delivery System <%s>",
+                         mail_addr_mail_daemon());
+       post_mail_fprintf(notice, "To: Postmaster <%s>", var_error_rcpt);
+    } else {
+       post_mail_fprintf(notice, "From: %s (Mail Delivery System)",
+                         mail_addr_mail_daemon());
+       post_mail_fprintf(notice, "To: %s (Postmaster)", var_error_rcpt);
+    }
     post_mail_fprintf(notice, "Subject: %s %s client: errors from %s",
                      var_mail_name, smtp_mode ? "SMTP" : "LMTP",
                      session->namaddrport);
index 493bfada1511f53b091d3c832c4606f605b43d79..ef65bc547e0b3da7875443c07c233fc81f459c32 100644 (file)
@@ -65,6 +65,7 @@
        VAR_SMTP_DSN_FILTER, DEF_SMTP_DSN_FILTER, &var_smtp_dsn_filter, 0, 0,
        VAR_SMTP_DNS_RE_FILTER, DEF_SMTP_DNS_RE_FILTER, &var_smtp_dns_re_filter, 0, 0,
        VAR_TLSPROXY_SERVICE, DEF_TLSPROXY_SERVICE, &var_tlsproxy_service, 1, 0,
+       VAR_HFROM_FORMAT, DEF_HFROM_FORMAT, &var_hfrom_format, 1, 0,
        0,
     };
     static const CONFIG_TIME_TABLE smtp_time_table[] = {
        VAR_SMTP_BALANCE_INET_PROTO, DEF_SMTP_BALANCE_INET_PROTO, &var_smtp_balance_inet_proto,
        0,
     };
-   static const CONFIG_NBOOL_TABLE smtp_nbool_table[] = {
+    static const CONFIG_NBOOL_TABLE smtp_nbool_table[] = {
        VAR_SMTP_REQ_DEADLINE, DEF_SMTP_REQ_DEADLINE, &var_smtp_req_deadline,
        0,
-   };
+    };
index 332d10f8cdc6e68e90d17044b0486757cf20c362..8c4132a30bc8523f97a046ff9129dd62be3b203f 100644 (file)
@@ -193,6 +193,7 @@ smtpd.o: ../../include/dsn_mask.h
 smtpd.o: ../../include/ehlo_mask.h
 smtpd.o: ../../include/events.h
 smtpd.o: ../../include/flush_clnt.h
+smtpd.o: ../../include/hfrom_format.h
 smtpd.o: ../../include/htable.h
 smtpd.o: ../../include/inet_proto.h
 smtpd.o: ../../include/info_log_addr_form.h
@@ -268,6 +269,7 @@ smtpd_chat.o: ../../include/check_arg.h
 smtpd_chat.o: ../../include/cleanup_user.h
 smtpd_chat.o: ../../include/dict.h
 smtpd_chat.o: ../../include/dns.h
+smtpd_chat.o: ../../include/hfrom_format.h
 smtpd_chat.o: ../../include/htable.h
 smtpd_chat.o: ../../include/int_filt.h
 smtpd_chat.o: ../../include/iostuff.h
index 7a51de67437512aa0ac92b7f8e96f956ab20de57..4f59dcae06564ef1650584bb21c19d32dbe6da6f 100644 (file)
 /*     The minimum plaintext data transfer rate in bytes/second for
 /*     DATA and BDAT requests, when deadlines are enabled with
 /*     smtpd_per_request_deadline.
+/* .IP "\fBheader_from_format (standard)\fR"
+/*     The format of the Postfix-generated \fBFrom:\fR header.
 /* TARPIT CONTROLS
 /* .ad
 /* .fi
 #include <match_parent_style.h>
 #include <normalize_mailhost_addr.h>
 #include <info_log_addr_form.h>
+#include <hfrom_format.h>
 
 /* Single-threaded server skeleton. */
 
@@ -1493,6 +1496,7 @@ int     var_smtpd_uproxy_tmout;
 bool    var_relay_before_rcpt_checks;
 bool    var_smtpd_req_deadline;
 int     var_smtpd_min_data_rate;
+char   *var_hfrom_format;
 
  /*
   * Silly little macros.
@@ -1586,6 +1590,11 @@ static int ask_client_cert;
   */
 static DICT *smtpd_cmd_filter;
 
+ /*
+  * Parsed header_from_format setting.
+  */
+int     smtpd_hfrom_format;
+
 #ifdef USE_SASL_AUTH
 
  /*
@@ -6362,6 +6371,11 @@ static void post_jail_init(char *unused_name, char **unused_argv)
        || var_smtpd_cmail_limit || var_smtpd_crcpt_limit
        || var_smtpd_cntls_limit || var_smtpd_cauth_limit)
        anvil_clnt = anvil_clnt_create();
+
+    /*
+     * header_from_format support, for postmaster notifications.
+     */
+    smtpd_hfrom_format = hfrom_format_parse(VAR_HFROM_FORMAT, var_hfrom_format);
 }
 
 MAIL_VERSION_STAMP_DECLARE;
@@ -6580,6 +6594,7 @@ int     main(int argc, char **argv)
        VAR_SMTPD_POLICY_CONTEXT, DEF_SMTPD_POLICY_CONTEXT, &var_smtpd_policy_context, 0, 0,
        VAR_SMTPD_DNS_RE_FILTER, DEF_SMTPD_DNS_RE_FILTER, &var_smtpd_dns_re_filter, 0, 0,
        VAR_SMTPD_REJ_FTR_MAPS, DEF_SMTPD_REJ_FTR_MAPS, &var_smtpd_rej_ftr_maps, 0, 0,
+       VAR_HFROM_FORMAT, DEF_HFROM_FORMAT, &var_hfrom_format, 1, 0,
        0,
     };
     static const CONFIG_RAW_TABLE raw_table[] = {
index 490cda2facf1a6c082a4bc47a2cc6a337556b472..0bb5bbbce026ede819a726baab49e831ecc4d47f 100644 (file)
@@ -417,6 +417,11 @@ extern MILTERS *smtpd_milters;
   */
 extern double smtpd_space_multf;
 
+ /*
+  * header_from_format support.
+  */
+extern int smtpd_hfrom_format;
+
 /* LICENSE
 /* .ad
 /* .fi
index c172ab3d15ae1da5aa3b87042cd758ed62a52963..278e5362ac71e40c498698ff59a665aa5a069886 100644 (file)
 #include <post_mail.h>
 #include <mail_error.h>
 #include <smtp_reply_footer.h>
+#include <hfrom_format.h>
 
 /* Application-specific. */
 
@@ -324,9 +325,15 @@ void    smtpd_chat_notify(SMTPD_STATE *state)
        msg_warn("postmaster notify: %m");
        return;
     }
-    post_mail_fprintf(notice, "From: %s (Mail Delivery System)",
-                     mail_addr_mail_daemon());
-    post_mail_fprintf(notice, "To: %s (Postmaster)", var_error_rcpt);
+    if (smtpd_hfrom_format == HFROM_FORMAT_CODE_STD) {
+       post_mail_fprintf(notice, "From: Mail Delivery System <%s>",
+                         mail_addr_mail_daemon());
+       post_mail_fprintf(notice, "To: Postmaster <%s>", var_error_rcpt);
+    } else {
+       post_mail_fprintf(notice, "From: %s (Mail Delivery System)",
+                         mail_addr_mail_daemon());
+       post_mail_fprintf(notice, "To: %s (Postmaster)", var_error_rcpt);
+    }
     post_mail_fprintf(notice, "Subject: %s SMTP server: errors from %s",
                      var_mail_name, state->namaddr);
     post_mail_fputs(notice, "");