summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Hazel <ph10@hermes.cam.ac.uk>2007-02-06 11:11:39 +0000
committerPhilip Hazel <ph10@hermes.cam.ac.uk>2007-02-06 11:11:39 +0000
commit0e22dfd114ef5e5db5913a5792a6d3a8df3b187b (patch)
tree7fcb1c065a694615934eab3439b21ac9b2eb59e0
parent0ce9abe687c08503facdd9f4f94dfa27ada83da9 (diff)
Added dsn_from to vary the contents of From: in DSNs
-rw-r--r--doc/doc-txt/ChangeLog4
-rw-r--r--doc/doc-txt/NewStuff12
-rw-r--r--src/src/deliver.c12
-rw-r--r--src/src/functions.h3
-rw-r--r--src/src/globals.c8
-rw-r--r--src/src/globals.h4
-rw-r--r--src/src/macros.h6
-rw-r--r--src/src/moan.c39
-rw-r--r--src/src/readconf.c3
-rw-r--r--test/confs/00321
-rw-r--r--test/mail/0032.CALLER2
11 files changed, 70 insertions, 24 deletions
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index f9485b632..d041a49d3 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.469 2007/02/06 10:00:24 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.470 2007/02/06 11:11:39 ph10 Exp $
Change log file for Exim from version 4.21
-------------------------------------------
@@ -75,6 +75,8 @@ PH/15 Flush SMTP output before delaying, unless control=no_delay_flush is set.
PH/16 Add ${if forany and ${if forall.
+PH/17 Added dsn_from option to vary the From: line in DSNs.
+
Exim version 4.66
-----------------
diff --git a/doc/doc-txt/NewStuff b/doc/doc-txt/NewStuff
index ff72f6fa6..43be722b0 100644
--- a/doc/doc-txt/NewStuff
+++ b/doc/doc-txt/NewStuff
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/NewStuff,v 1.136 2007/02/06 10:00:24 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/NewStuff,v 1.137 2007/02/06 11:11:39 ph10 Exp $
New Features in Exim
--------------------
@@ -268,6 +268,16 @@ Version 4.67
Its value is saved and restored while forany/forall is being processed, to
enable these expansion items to be nested.
+13. There's a new global option called dsn_from that can be used to vary the
+ contents of From: lines in bounces and other automatically generated
+ messages ("delivery status notifications" - hence the name of the option).
+ The default setting is:
+
+ dsn_from = Mail Delivery System <Mailer-Daemon@$qualify_domain>
+
+ The value is expanded every time it is needed. If the expansion fails, a
+ panic is logged, and the default setting is used.
+
Version 4.66
------------
diff --git a/src/src/deliver.c b/src/src/deliver.c
index 4bc8c5f2c..be588dd7c 100644
--- a/src/src/deliver.c
+++ b/src/src/deliver.c
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/deliver.c,v 1.42 2007/01/23 12:33:08 magnus Exp $ */
+/* $Cambridge: exim/src/src/deliver.c,v 1.43 2007/02/06 11:11:40 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -2043,9 +2043,7 @@ if (addr->special_action == SPECIAL_WARN &&
!contains_header(US"Reply-To", warn_message))
fprintf(f, "Reply-To: %s\n", errors_reply_to);
fprintf(f, "Auto-Submitted: auto-replied\n");
- if (!contains_header(US"From", warn_message))
- fprintf(f, "From: Mail Delivery System <Mailer-Daemon@%s>\n",
- qualify_domain_sender);
+ if (!contains_header(US"From", warn_message)) moan_write_from(f);
fprintf(f, "%s", CS warn_message);
/* Close and wait for child process to complete, without a timeout. */
@@ -6248,8 +6246,7 @@ while (addr_failed != NULL)
if (errors_reply_to != NULL)
fprintf(f, "Reply-To: %s\n", errors_reply_to);
fprintf(f, "Auto-Submitted: auto-replied\n");
- fprintf(f, "From: Mail Delivery System <Mailer-Daemon@%s>\n",
- qualify_domain_sender);
+ moan_write_from(f);
fprintf(f, "To: %s\n", bounce_recipient);
/* Open a template file if one is provided. Log failure to open, but
@@ -6773,8 +6770,7 @@ else if (addr_defer != (address_item *)(+1))
if (errors_reply_to != NULL)
fprintf(f, "Reply-To: %s\n", errors_reply_to);
fprintf(f, "Auto-Submitted: auto-replied\n");
- fprintf(f, "From: Mail Delivery System <Mailer-Daemon@%s>\n",
- qualify_domain_sender);
+ moan_write_from(f);
fprintf(f, "To: %s\n", recipients);
wmf_text = next_emf(wmf, US"header");
diff --git a/src/src/functions.h b/src/src/functions.h
index 5e3f9d580..f71b5aa99 100644
--- a/src/src/functions.h
+++ b/src/src/functions.h
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/functions.h,v 1.34 2007/01/18 15:35:42 ph10 Exp $ */
+/* $Cambridge: exim/src/src/functions.h,v 1.35 2007/02/06 11:11:40 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -170,6 +170,7 @@ extern void moan_smtp_batch(uschar *, char *, ...);
extern void moan_tell_someone(uschar *, address_item *, uschar *, char *,
...);
extern BOOL moan_to_sender(int, error_block *, header_line *, FILE *, BOOL);
+extern void moan_write_from(FILE *);
extern FILE *modefopen(uschar *, char *, mode_t);
extern uschar *parse_extract_address(uschar *, uschar **, int *, int *, int *,
diff --git a/src/src/globals.c b/src/src/globals.c
index 4d790ee9e..a8122d0bc 100644
--- a/src/src/globals.c
+++ b/src/src/globals.c
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/globals.c,v 1.69 2007/02/06 10:00:24 ph10 Exp $ */
+/* $Cambridge: exim/src/src/globals.c,v 1.70 2007/02/06 11:11:40 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -526,6 +526,7 @@ int domainlist_count = 0;
BOOL dont_deliver = FALSE;
BOOL dot_ends = TRUE;
BOOL drop_cr = FALSE; /* No longer used */
+uschar *dsn_from = US DEFAULT_DSN_FROM;
BOOL enable_dollar_recipients = FALSE;
BOOL envelope_to_remove = TRUE;
@@ -551,7 +552,10 @@ BOOL extract_addresses_remove_arguments = TRUE;
uschar *extra_local_interfaces = NULL;
int fake_response = OK;
-uschar *fake_response_text = US"Your message has been rejected but is being kept for evaluation.\nIf it was a legitimate message, it may still be delivered to the target recipient(s).";
+uschar *fake_response_text = US"Your message has been rejected but is "
+ "being kept for evaluation.\nIf it was a "
+ "legitimate message, it may still be "
+ "delivered to the target recipient(s).";
int filter_n[FILTER_VARIABLE_COUNT];
BOOL filter_running = FALSE;
int filter_sn[FILTER_VARIABLE_COUNT];
diff --git a/src/src/globals.h b/src/src/globals.h
index 77662b376..09674f22b 100644
--- a/src/src/globals.h
+++ b/src/src/globals.h
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/globals.h,v 1.49 2007/02/06 10:00:24 ph10 Exp $ */
+/* $Cambridge: exim/src/src/globals.h,v 1.50 2007/02/06 11:11:40 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -308,6 +308,8 @@ extern BOOL dot_ends; /* TRUE if "." ends non-SMTP input */
/* This option is now a no-opt, retained for compatibility */
extern BOOL drop_cr; /* For broken local MUAs */
+extern uschar *dsn_from; /* From: string for DSNs */
+
extern BOOL enable_dollar_recipients; /* Make $recipients available */
extern int envelope_to_remove; /* Remove envelope_to_headers */
extern int errno_quota; /* Quota errno in this OS */
diff --git a/src/src/macros.h b/src/src/macros.h
index f73ce63ac..00e040b5f 100644
--- a/src/src/macros.h
+++ b/src/src/macros.h
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/macros.h,v 1.31 2007/01/31 16:52:12 ph10 Exp $ */
+/* $Cambridge: exim/src/src/macros.h,v 1.32 2007/02/06 11:11:40 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -97,6 +97,10 @@ don't make the file descriptors two-way. */
#define DEBUG(x) if ((debug_selector & (x)) != 0)
#define HDEBUG(x) if (host_checking || (debug_selector & (x)) != 0)
+/* The default From: text for DSNs */
+
+#define DEFAULT_DSN_FROM "Mail Delivery System <Mailer-Daemon@$qualify_domain>"
+
/* The size of the vector for saving/restoring address expansion pointers while
verifying. This has to be explicit because it is referenced in more than one
source module. */
diff --git a/src/src/moan.c b/src/src/moan.c
index 4503a47e5..5ef5fe42c 100644
--- a/src/src/moan.c
+++ b/src/src/moan.c
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/moan.c,v 1.7 2007/01/08 10:50:18 ph10 Exp $ */
+/* $Cambridge: exim/src/src/moan.c,v 1.8 2007/02/06 11:11:40 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -15,6 +15,34 @@
/*************************************************
+* Write From: line for DSN *
+*************************************************/
+
+/* This function is called to write the From: line in automatically generated
+messages - bounces, warnings, etc. It expands a configuration item in order to
+get the text. If the expansion fails, a panic is logged and the default value
+for the option is used.
+
+Argument: the FILE to write to
+Returns: nothing
+*/
+
+void
+moan_write_from(FILE *f)
+{
+uschar *s = expand_string(dsn_from);
+if (s == NULL)
+ {
+ log_write(0, LOG_MAIN|LOG_PANIC,
+ "Failed to expand dsn_from (using default): %s", expand_string_message);
+ s = expand_string(US DEFAULT_DSN_FROM);
+ }
+fprintf(f, "From: %s\n", s);
+}
+
+
+
+/*************************************************
* Send error message *
*************************************************/
@@ -62,8 +90,7 @@ else DEBUG(D_any) debug_printf("Child process %d for sending message\n", pid);
f = fdopen(fd, "wb");
if (errors_reply_to != NULL) fprintf(f, "Reply-To: %s\n", errors_reply_to);
fprintf(f, "Auto-Submitted: auto-replied\n");
-fprintf(f, "From: Mail Delivery System <Mailer-Daemon@%s>\n",
- qualify_domain_sender);
+moan_write_from(f);
fprintf(f, "To: %s\n", recipient);
switch(ident)
@@ -427,8 +454,7 @@ if (pid < 0)
f = fdopen(fd, "wb");
fprintf(f, "Auto-Submitted: auto-replied\n");
-fprintf(f, "From: Mail Delivery System <Mailer-Daemon@%s>\n",
- qualify_domain_sender);
+moan_write_from(f);
fprintf(f, "To: %s\n", who);
fprintf(f, "Subject: %s\n\n", subject);
va_start(ap, format);
@@ -671,8 +697,7 @@ if (pid < 0)
f = fdopen(fd, "wb");
fprintf(f, "Auto-Submitted: auto-replied\n");
-fprintf(f, "From: Mail Delivery System <Mailer-Daemon@%s>\n",
- qualify_domain_sender);
+moan_write_from(f);
fprintf(f, "To: %s\n", s);
fprintf(f, "Subject: error(s) in forwarding or filtering\n\n");
diff --git a/src/src/readconf.c b/src/src/readconf.c
index 1b4a04b66..a599ea81f 100644
--- a/src/src/readconf.c
+++ b/src/src/readconf.c
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/readconf.c,v 1.28 2007/01/22 16:29:54 ph10 Exp $ */
+/* $Cambridge: exim/src/src/readconf.c,v 1.29 2007/02/06 11:11:40 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -209,6 +209,7 @@ static optionlist optionlist_config[] = {
/* This option is now a no-op, retained for compability */
{ "drop_cr", opt_bool, &drop_cr },
/*********************************************************/
+ { "dsn_from", opt_stringptr, &dsn_from },
{ "envelope_to_remove", opt_bool, &envelope_to_remove },
{ "errors_copy", opt_stringptr, &errors_copy },
{ "errors_reply_to", opt_stringptr, &errors_reply_to },
diff --git a/test/confs/0032 b/test/confs/0032
index 7ec81cc20..fc2f22cd2 100644
--- a/test/confs/0032
+++ b/test/confs/0032
@@ -12,6 +12,7 @@ gecos_name = CALLER_NAME
# ----- Main settings -----
+dsn_from = MailProgram <xyz@some.where>
# ----- Routers -----
diff --git a/test/mail/0032.CALLER b/test/mail/0032.CALLER
index 034296f5b..95051c4d9 100644
--- a/test/mail/0032.CALLER
+++ b/test/mail/0032.CALLER
@@ -7,7 +7,7 @@ Received: from EXIMUSER by myhost.ex with local (Exim x.yz)
for CALLER@myhost.ex; Tue, 2 Mar 1999 09:44:33 +0000
X-Failed-Recipients: userx@mxt1.test.ex
Auto-Submitted: auto-replied
-From: Mail Delivery System <Mailer-Daemon@myhost.ex>
+From: MailProgram <xyz@some.where>
To: CALLER@myhost.ex
Subject: Mail delivery failed: returning message to sender
Message-Id: <E10HmaY-0005vi-00@myhost.ex>