Update version number and copyright year.
[exim.git] / src / src / routers / rf_get_errors_address.c
index e2e75424ce84113ad49c4a9505f4bea5866561f3..bfc6bf306284a3eb9715feacf42e8706037220c4 100644 (file)
@@ -1,10 +1,10 @@
-/* $Cambridge: exim/src/src/routers/rf_get_errors_address.c,v 1.1 2004/10/07 13:10:02 ph10 Exp $ */
+/* $Cambridge: exim/src/src/routers/rf_get_errors_address.c,v 1.7 2007/01/08 10:50:20 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
-/* Copyright (c) University of Cambridge 1995 - 2004 */
+/* Copyright (c) University of Cambridge 1995 - 2007 */
 /* See the file NOTICE for conditions of use and distribution. */
 
 #include "../exim.h"
@@ -26,7 +26,7 @@ configuration.
 Arguments:
   addr         the input address
   rblock       the router instance
-  verify       TRUE when verifying
+  verify       v_none / v_recipient / v_sender / v_expn
   errors_to    point the errors address here
 
 Returns:       OK if no problem
@@ -36,7 +36,7 @@ Returns:       OK if no problem
 
 int
 rf_get_errors_address(address_item *addr, router_instance *rblock,
-  BOOL verify, uschar **errors_to)
+  int verify, uschar **errors_to)
 {
 uschar *s;
 
@@ -75,7 +75,7 @@ of routers by checking the sender address. When testing an address, there may
 not be a sender address. We also need to save and restore the expansion values
 associated with an address. */
 
-if (verify)
+if (verify != v_none)
   {
   *errors_to = s;
   DEBUG(D_route)
@@ -100,10 +100,23 @@ else
     address_expansions_save[i++] = **p++;
   address_test_mode = FALSE;
 
+  /* NOTE: the address is verified as a recipient, not a sender. This is
+  perhaps confusing. It isn't immediately obvious what to do: we want to have
+  some confidence that we can deliver to the address, in which case it will be
+  a recipient, but on the other hand, it will be passed on in SMTP deliveries
+  as a sender. However, I think on balance recipient is right because sender
+  verification is really about the *incoming* sender of the message.
+
+  If this code is changed, note that you must set vopt_fake_sender instead of
+  vopt_is_recipient, as otherwise sender_address may be altered because
+  verify_address() thinks it is dealing with *the* sender of the message. */
+
   DEBUG(D_route|D_verify)
     debug_printf("------ Verifying errors address %s ------\n", s);
-  if (verify_address(snew, NULL, vopt_is_recipient | vopt_qualify, -1, -1,
-    NULL, NULL, NULL) == OK) *errors_to = snew->address;
+  if (verify_address(snew, NULL,
+      vopt_is_recipient /* vopt_fake_sender is the alternative */
+      | vopt_qualify, -1, -1, -1, NULL, NULL, NULL) == OK)
+    *errors_to = snew->address;
   DEBUG(D_route|D_verify)
     debug_printf("------ End verifying errors address %s ------\n", s);