Hi, I've noticed that Postfix' /usr/bin/sendmail interface supports almost full control of the DSNs, similar to what one gets when talking ESMTP. The only missing point is control of RET=HDRS vs. RET=FULL.
All of the required pieces in the backend were already present because the ESMTP service needs them, so the attached patch is rather trivial and mostly touches just the sendmail.c. There's also a one-liner fixing the comment in the header defining the REC_TYPE_DSN_ENVID. Please feel free to adjust the coding style and documentation to better fit the existing code (and I'm sorry for messing up the tabs), or modify the patch in any way. Can this possible become a part of a future Postfix release? With kind regards, Jan -- Trojita, a fast e-mail client -- http://trojita.flaska.net/
diff -Naurt postfix-2.10-20120801.orig//man/man1/sendmail.1
postfix-2.10-20120801/man/man1/sendmail.1
--- postfix-2.10-20120801.orig//man/man1/sendmail.1 2012-06-30
23:48:48.000000000 +0200
+++ postfix-2.10-20120801/man/man1/sendmail.1 2012-08-24 18:46:45.956482577
+0200
@@ -179,9 +179,10 @@
Set the envelope sender address. This is the address where
delivery problems are sent to. With Postfix versions before 2.1, the
\fBErrors-To:\fR message header overrides the error return address.
-.IP "\fB-R \fIreturn_limit\fR (ignored)"
-Limit the size of bounced mail. Use the \fBbounce_size_limit\fR
-configuration parameter instead.
+.IP "\fB-R \fIreturn_limit\fR"
+Limit the size of bounced mail ("full" or "hdrs").
+
+Supported since 2.10, ignored in earlier versions.
.IP \fB-q\fR
Attempt to deliver all queued mail. This is implemented by
executing the \fBpostqueue\fR(1) command.
diff -Naurt postfix-2.10-20120801.orig//src/global/rec_type.h
postfix-2.10-20120801/src/global/rec_type.h
--- postfix-2.10-20120801.orig//src/global/rec_type.h 2007-03-20
16:25:10.000000000 +0100
+++ postfix-2.10-20120801/src/global/rec_type.h 2012-08-24 18:24:28.093450782
+0200
@@ -68,7 +68,7 @@
#define REC_TYPE_VERP 'V' /* VERP delimiters */
#define REC_TYPE_DSN_RET '<' /* DSN full/hdrs */
-#define REC_TYPE_DSN_ENVID 'i' /* DSN full/hdrs */
+#define REC_TYPE_DSN_ENVID 'i' /* DSN envelope id */
#define REC_TYPE_DSN_ORCPT 'o' /* DSN orig rcpt address */
#define REC_TYPE_DSN_NOTIFY 'n' /* DSN notify flags */
diff -Naurt postfix-2.10-20120801.orig//src/sendmail/sendmail.c
postfix-2.10-20120801/src/sendmail/sendmail.c
--- postfix-2.10-20120801.orig//src/sendmail/sendmail.c 2012-06-30
23:48:46.000000000 +0200
+++ postfix-2.10-20120801/src/sendmail/sendmail.c 2012-08-24
18:45:38.852480983 +0200
@@ -173,9 +173,9 @@
/* Set the envelope sender address. This is the address where
/* delivery problems are sent to. With Postfix versions before 2.1, the
/* \fBErrors-To:\fR message header overrides the error return address.
-/* .IP "\fB-R \fIreturn_limit\fR (ignored)"
-/* Limit the size of bounced mail. Use the \fBbounce_size_limit\fR
-/* configuration parameter instead.
+/* .IP "\fB-R \fIreturn_limit\fR"
+/* Limit the size of bounced mail ("full" or "hdrs").
+/* Supported since 2.10, ignored in earlier versions.
/* .IP \fB-q\fR
/* Attempt to deliver all queued mail. This is implemented by
/* executing the \fBpostqueue\fR(1) command.
@@ -605,7 +605,7 @@
/* enqueue - post one message */
static void enqueue(const int flags, const char *encoding,
- const char *dsn_envid, int dsn_notify,
+ const char *dsn_envid, int dsn_notify, int dsn_ret,
const char *rewrite_context, const char *sender,
const char *full_name, char **recipients)
{
@@ -744,6 +744,9 @@
if (dsn_notify)
rec_fprintf(dst, REC_TYPE_ATTR, "%s=%d",
MAIL_ATTR_DSN_NOTIFY, dsn_notify);
+ if (dsn_ret)
+ rec_fprintf(dst, REC_TYPE_ATTR, "%s=%d",
+ MAIL_ATTR_DSN_RET, dsn_ret);
if (REC_PUT_BUF(dst, REC_TYPE_RCPT, buf) < 0)
msg_fatal_status(EX_TEMPFAIL,
"%s(%ld): error writing queue file: %m",
@@ -883,6 +886,10 @@
if (dsn_notify)
rec_fprintf(dst, REC_TYPE_ATTR, "%s=%d",
MAIL_ATTR_DSN_NOTIFY, dsn_notify);
+ if (dsn_ret)
+ rec_fprintf(dst, REC_TYPE_ATTR, "%s=%d",
+ MAIL_ATTR_DSN_RET, dsn_ret);
+
if (rec_put(dst, REC_TYPE_RCPT, *cpp, strlen(*cpp)) < 0)
msg_fatal_status(EX_TEMPFAIL,
"%s(%ld): error writing queue file: %m",
@@ -970,6 +977,7 @@
uid_t uid;
const char *rewrite_context = MAIL_ATTR_RWR_LOCAL;
int dsn_notify = 0;
+ int dsn_ret = 0;
const char *dsn_envid = 0;
int saved_optind;
@@ -1162,6 +1170,10 @@
if ((dsn_notify = dsn_notify_mask(optarg)) == 0)
msg_warn("bad -N option value -- ignored");
break;
+ case 'R':
+ if ((dsn_ret = dsn_ret_code(optarg)) == 0)
+ msg_warn("bad -R option value -- ignored");
+ break;
case 'V': /* DSN, was: VERP */
if (strlen(optarg) > 100)
msg_warn("too long -V option value -- ignored");
@@ -1289,6 +1301,8 @@
msg_fatal_status(EX_USAGE, "-t option cannot be used with -bv");
if (dsn_notify)
msg_fatal_status(EX_USAGE, "-N option cannot be used with -bv");
+ if (dsn_ret)
+ msg_fatal_status(EX_USAGE, "-R option cannot be used with -bv");
if (msg_verbose == 1)
msg_fatal_status(EX_USAGE, "-v option cannot be used with -bv");
}
@@ -1333,7 +1347,7 @@
mail_run_replace(var_command_dir, ext_argv->argv);
/* NOTREACHED */
} else {
- enqueue(flags, encoding, dsn_envid, dsn_notify,
+ enqueue(flags, encoding, dsn_envid, dsn_notify, dsn_ret,
rewrite_context, sender, full_name, argv + OPTIND);
exit(0);
/* NOTREACHED */
signature.asc
Description: OpenPGP digital signature
