-/* $Cambridge: exim/src/src/routers/dnslookup.c,v 1.5 2005/09/12 15:09:55 ph10 Exp $ */
+/* $Cambridge: exim/src/src/routers/dnslookup.c,v 1.7 2005/09/19 09:41:37 fanf2 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
verification purposes, but never at transport time, so any header changes that
you might expect as a result of sender domain widening do not occur. Therefore
we do not perform widening when verifying sender addresses; however, widening
-sender addresses is OK if we do not have to rewrite the headers. The
-suppression of widening for sender addresses is silent because it is the normal
-desirable behaviour. */
-
-if (ob->widen_domains != NULL && (verify != v_sender || !ob->rewrite_headers))
+sender addresses is OK if we do not have to rewrite the headers. A corollary
+of this is that if the current address is not the original address, then it
+does not appear in the message header so it is also OK to widen. The
+suppression of widening for sender addresses is silent because it is the
+normal desirable behaviour. */
+
+if (ob->widen_domains != NULL &&
+ (verify != v_sender || !ob->rewrite_headers || addr->parent != NULL))
{
listptr = ob->widen_domains;
widen = string_nextinlist(&listptr, &widen_sep, widen_buffer,
/* Unfortunately, we cannot set the mx_only option in advance, because the
DNS lookup may extend an unqualified name. Therefore, we must do the test
- subsequently. */
+ subsequently. We use the same logic as that for widen_domains above to avoid
+ requesting a header rewrite that cannot work. */
- if (ob->qualify_single) flags |= HOST_FIND_QUALIFY_SINGLE;
- if (ob->search_parents) flags |= HOST_FIND_SEARCH_PARENTS;
+ if (verify != v_sender || !ob->rewrite_headers || addr->parent != NULL)
+ {
+ if (ob->qualify_single) flags |= HOST_FIND_QUALIFY_SINGLE;
+ if (ob->search_parents) flags |= HOST_FIND_SEARCH_PARENTS;
+ }
rc = host_find_bydns(&h, rblock->ignore_target_hosts, flags, srv_service,
ob->srv_fail_domains, ob->mx_fail_domains, &fully_qualified_name, &removed);