Hello,

DSN for successfully deliveries are not enabled by default. They have to be requested
by an smtp client using extra parameter on RFC5321.MAILFROM an RFC5321.RCPTTO

But not every MUA has the ability to do this. Some years ago I had a requirement to force DSN on successfully deliveries for every message send by a simple smtp client as a dedicated mailstream.

So I wrote a little patch to let postfix smtpd insert the necessary data.
The function must be enabled by an new option. Now other people told me they find that feature useful too. So I like to publish that patch. Maybe it could be included in postfix some day.

usage: master.cf
submission inet  n - n - - smtpd
 -o syslog_name=postfix/submission_with_dsn
 -o smtpd_force_dsn_on_success=yes


Andreas

Index: postfix-2.11.0/src/global/mail_params.h
===================================================================
--- postfix-2.11.0.orig/src/global/mail_params.h	2013-12-29 02:27:16.000000000 +0100
+++ postfix-2.11.0/src/global/mail_params.h	2014-01-16 21:33:02.000000000 +0100
@@ -3744,6 +3744,14 @@
 #define DEF_DAEMON_OPEN_FATAL	0
 extern bool var_daemon_open_fatal;
 
+ /*
+  * some(most?) mailclients cannot request "NOTIFY=SUCCESS" on RCPT TO:
+  * we do it for him ...
+  */
+#define VAR_FORCE_DSN_ON_SUCCESS       "smtpd_force_dsn_on_success"
+#define DEF_FORCE_DSN_ON_SUCCESS       0
+extern bool var_force_dsn_on_success;
+
 /* LICENSE
 /* .ad
 /* .fi
Index: postfix-2.11.0/src/smtpd/smtpd.c
===================================================================
--- postfix-2.11.0.orig/src/smtpd/smtpd.c	2014-01-06 19:52:27.000000000 +0100
+++ postfix-2.11.0/src/smtpd/smtpd.c	2014-01-16 21:33:02.000000000 +0100
@@ -1298,6 +1298,7 @@
 char   *var_milt_unk_macros;
 bool    var_smtpd_client_port_log;
 char   *var_stress;
+bool   var_force_dsn_on_success;
 
 char   *var_reject_tmpf_act;
 char   *var_unk_name_tf_act;
@@ -2607,6 +2608,11 @@
 			    "501 5.5.4 Error: Bad NOTIFY parameter syntax");
 		return (-1);
 	    }
+            /*
+             * the client _is_ able to send NOTIFY=*
+             * no need to enforce anything
+             */
+            var_force_dsn_on_success = 0;
 	} else if (strncasecmp(arg, "ORCPT=", 6) == 0) {	/* RFC 3461 */
 	    /* Sanitized by bounce server. */
 	    if (state->ehlo_discard_mask & EHLO_MASK_DSN) {
@@ -2751,6 +2757,8 @@
 		dsn_orcpt_addr_len -= 2;
 	    }
 	}
+        if (var_force_dsn_on_success)
+            dsn_notify = DSN_NOTIFY_ANY;
 	if (dsn_notify)
 	    rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%d",
 			MAIL_ATTR_DSN_NOTIFY, dsn_notify);
@@ -5359,6 +5367,7 @@
 	VAR_SMTPD_PEERNAME_LOOKUP, DEF_SMTPD_PEERNAME_LOOKUP, &var_smtpd_peername_lookup,
 	VAR_SMTPD_DELAY_OPEN, DEF_SMTPD_DELAY_OPEN, &var_smtpd_delay_open,
 	VAR_SMTPD_CLIENT_PORT_LOG, DEF_SMTPD_CLIENT_PORT_LOG, &var_smtpd_client_port_log,
+        VAR_FORCE_DSN_ON_SUCCESS, DEF_FORCE_DSN_ON_SUCCESS, &var_force_dsn_on_success,
 	0,
     };
     static const CONFIG_NBOOL_TABLE nbool_table[] = {

Reply via email to