diff -urw sendmail-8.13.3-orig/sendmail/conf.c sendmail-8.13.3-mxaddr/sendmail/conf.c
--- sendmail-8.13.3-orig/sendmail/conf.c	2004-12-15 17:45:55.000000000 -0500
+++ sendmail-8.13.3-mxaddr/sendmail/conf.c	2005-03-30 23:20:20.000000000 -0500
@@ -6065,6 +6065,54 @@
 	/* Allow usernames with '.' */
 	"_FFR_DOTTED_USERNAMES",
 #endif /* _FFR_DOTTED_USERNAMES */
+#if _FFR_MX_A_REC_INCLASSW
+	/* Lookup MX records A/AAAA records to see
+	 * if they exist in class w, and if so, treat as if
+	 * the MX was found in class w and replace the
+	 * MX record name with the value matched in class w
+	 *
+	 * So put [your.mx.ip.addr] in local-host-names to 
+	 * use this effectively.
+	 *
+	 * While only generally usefull when combined with
+	 * FEATURE(`bestmx_is_local') without said feature
+	 * this will change the error message of
+	 * "mail loops back to me"
+	 * to
+	 * "mx list for X points back  to Y"
+	 *
+	 * Meaning that sendmail does not try to talk to itself
+	 * in this case.
+	 *
+	 * Also this sentence from RFC2821, "The relay host MUST
+	 * then inspect the list for any of the names or 
+	 * _addresses_ [emphasis addeded] by which it might 
+	 * be known in mail transactions." , seems to indicate 
+	 * that this is proper behavior.
+	 */
+	"_FFR_MX_A_REC_INCLASSW",
+#endif /* _FFR_MX_A_REC_INCLASSW */ 
+#if _FFR_MX_NOHOST_SKIP
+	/* Skip mx records that dont resolve.
+	 * Currently, if the most preferred MX record does
+	 * not resolve to a host, the message will be bounced.
+	 *
+	 * This will mask that problem if there are no
+	 * resolvable MX's, they wont show up as host
+	 * not found. Also TryNullMXList will be used.
+	 */
+	"_FFR_MX_NOHOST_SKIP",
+#endif /* _FFR_MX_NOHOST_SKIP */
+#if _FFR_MX_NOHOST_HIPREF
+	/* As an alternative to _FFR_MX_NOHOST_SKIP
+	 * this will set the MX with a high preference
+	 * value causing it to be the least preferred MX
+	 *
+	 * If we spot ourselves with a lower priority, then
+	 * the unresolvable address will effectively get cut off.
+	 */
+	"_FFR_MX_NOHOST_HIPREF",
+#endif /* _FFR_MX_NOHOST_HIPREF */
 #if _FFR_DROP_TRUSTUSER_WARNING
 	/*
 	**  Don't issue this warning:
diff -urw sendmail-8.13.3-orig/sendmail/domain.c sendmail-8.13.3-mxaddr/sendmail/domain.c
--- sendmail-8.13.3-orig/sendmail/domain.c	2004-08-04 17:11:31.000000000 -0400
+++ sendmail-8.13.3-mxaddr/sendmail/domain.c	2005-03-31 08:59:06.340612155 -0500
@@ -78,6 +78,9 @@
 
 static int	mxrand __P((char *));
 static int	fallbackmxrr __P((int, unsigned short *, char **));
+# if _FFR_MX_A_REC_INCLASSW || _FFR_MX_NOHOST_SKIP || _FFR_MX_NOHOST_HIPREF
+static int	hostaddrinclass __P((char *, int, char **));
+# endif /* _FFR_MX_A_REC_INCLASSW || _FFR_MX_NOHOST_SKIP || _FFR_MX_NOHOST_HIPREF */
 
 /*
 **  GETFALLBACKMXRR -- get MX resource records for fallback MX host.
@@ -228,6 +231,12 @@
 	int weight[MAXMXHOSTS];
 	int ttl = 0;
 	extern int res_query(), res_search();
+# if _FFR_MX_A_REC_INCLASSW
+	char *addrclbuf = NULL;
+# endif /* _FFR_MX_A_REC_INCLASSW */
+# if _FFR_MX_A_REC_INCLASSW || _FFR_MX_NOHOST_SKIP || _FFR_MX_NOHOST_HIPREF
+	int addrcl_ret = 0;
+# endif /* _FFR_MX_A_REC_INCLASSW || _FFR_MX_NOHOST_SKIP || _FFR_MX_NOHOST_HIPREF */
 
 	if (tTd(8, 2))
 		sm_dprintf("getmxrr(%s, droplocalhost=%d)\n",
@@ -377,7 +386,33 @@
 			continue;
 		}
 # endif /* 0 */
+# if _FFR_MX_NOHOST_SKIP || _FFR_MX_NOHOST_HIPREF
+		addrcl_ret = hostaddrinclass(bp, 'w', 
+#  if _FFR_MX_A_REC_INCLASSW
+			((droplocalhost) ? NULL : &addrclbuf )
+#  else /* _FFR_MX_A_REC_INCLASSW */
+			NULL
+#  endif /* _FFR_MX_A_REC_INCLASSW */
+			);
+#  if _FFR_MX_NOHOST_SKIP
+		if (addrcl_ret <= (EX_OK - 2))
+			continue;
+#  endif /* _FFR_MX_NOHOST_SKIP */
+#  if _FFR_MX_A_REC_INCLASSW
+		if (wordinclass(bp, 'w') || addrcl_ret > EX_OK)
+#  else /* _FFR_MX_A_REC_INCLASSW */
+		if (wordinclass(bp, 'w')) 
+#  endif /* _FFR_MX_A_REC_INCLASSW */
+# else /* _FFR_MX_NOHOST_SKIP || _FFR_MX_NOHOST_HIPREF */
+#  if _FFR_MX_A_REC_INCLASSW
+		if (wordinclass(bp, 'w') || 
+		    (hostaddrinclass(bp, 'w', 
+			((droplocalhost) ? NULL : &addrclbuf ) ) > EX_OK) 
+		    )
+#  else /* _FFR_MX_A_REC_INCLASSW */
 		if (wordinclass(bp, 'w'))
+#  endif /* _FFR_MX_A_REC_INCLASSW */
+# endif /* _FFR_MX_NOHOST_SKIP || _FFR_MX_NOHOST_HIPREF */
 		{
 			if (tTd(8, 3))
 				sm_dprintf("found localhost (%s) in MX list, pref=%d\n",
@@ -390,9 +425,24 @@
 				continue;
 			}
 			weight[nmx] = 0;
+			
+# if _FFR_MX_A_REC_INCLASSW
+			if (addrclbuf)
+			{
+				n = strlen(addrclbuf);
+				sm_strlcpy(bp, addrclbuf, buflen);
+				sm_free(addrclbuf);
+				addrclbuf = NULL;
+			}
+# endif /* _FFR_MX_A_REC_INCLASSW */
 		}
 		else
 			weight[nmx] = mxrand(bp);
+# if _FFR_MX_NOHOST_HIPREF
+		if (addrcl_ret <= (EX_OK - 2))
+			prefs[nmx] = 65535;
+		else
+# endif /*_FFR_MX_NOHOST_HIPREF */
 		prefs[nmx] = pref;
 		mxhosts[nmx++] = bp;
 		bp += n;
@@ -1165,4 +1215,138 @@
 		*pttl = ttl;
 	return true;
 }
+
+
+
+#if _FFR_MX_A_REC_INCLASSW || _FFR_MX_NOHOST_SKIP || _FFR_MX_NOHOST_HIPREF
+/*
+**  Check if any of a host's numerical address are in a class
+**  Can also be used to test resolvability of a MX
+**  Parameters:
+**	host -- a char buffer containing name to lookup
+**	cl -- class
+**	buf -- address of pointer to char
+**
+**  Return:
+**	EX_OK if no match and no error
+**	EX_OK + 1 if match
+**	EX_OK - 1 if transient error
+**	EX_OK - 2 if perm error
+**
+**  Side Effects:
+**	if buf is not NULL and return is > EX_OK
+**      buf will contain address of allocated string
+**	containing bracketed IP address of host that
+**	was in class. This string is owned by caller.
+** 
+*/
+
+static int
+hostaddrinclass(host, cl, buf)
+	char * host;
+	int cl;
+	char ** buf;
+{
+	char * localbuf = NULL;
+	int i = 0;
+	int ret_code = EX_OK;
+	struct hostent * h = NULL; 
+	int save_errno = errno;
+	int save_h_errno = h_errno;
+# ifdef NETINET
+	struct in_addr ia;
+# endif /* NETINET */
+# ifdef NETINET6
+	struct in6_addr ia6;
+	char addrbuf[INET6_ADDRSTRLEN+4];
+# else
+	char addrbuf[INET_ADDRSTRLEN+4];
+# endif	/* NETINET6 */
+
+	addrbuf[0] = '[';
+# ifdef NETINET
+	SM_SET_H_ERRNO(0);
+	errno = 0;
+	h = sm_gethostbyname(host, AF_INET);
+	if (h == NULL)
+	{
+		if (errno == ETIMEDOUT ||
+		    h_errno == TRY_AGAIN ||
+		    (errno == ECONNREFUSED &&
+		     UseNameServer))
+			ret_code = EX_OK - 1;
+		else
+			ret_code = EX_OK - 2;
+	}
+	else
+	{
+		while(h->h_addr_list[i])
+		{
+			int addrlen;
+
+			memcpy(&ia, h->h_addr_list[i], sizeof(ia));
+			inet_ntop(AF_INET, &ia , (addrbuf+1), sizeof(addrbuf) - 2);
+			addrlen = strlen(addrbuf);
+			addrbuf[addrlen++] = ']';
+			addrbuf[addrlen++] = '\0';
+			if (wordinclass(addrbuf, 'w'))
+			{
+				if (buf && !localbuf)
+					localbuf = newstr(addrbuf);
+				ret_code++;
+			}
+			i++;
+		}
+	}	
+# endif /* NETINET */
+# if NETINET6
+	if (ret_code > EX_OK)
+		goto finish_up;
+	SM_SET_H_ERRNO(0);
+	errno = 0;
+	h = sm_gethostbyname(host, AF_INET6);
+	if (h == NULL)
+	{
+		if (errno == ETIMEDOUT ||
+		    h_errno == TRY_AGAIN ||
+		    (errno == ECONNREFUSED &&
+		     UseNameServer))
+			ret_code = EX_OK - 1;
+		else
+			ret_code = EX_OK - 2;
+	}
+	else
+	{
+		while(h->h_addr_list[i])
+		{ 
+			int addrlen;
+
+			memcpy(&ia6, h->h_addr_list[i], sizeof(ia6));
+			inet_ntop(AF_INET6, &ia6, (addrbuf+1), sizeof(addrbuf) - 2);
+			addrlen = strlen(addrbuf);
+			addrbuf[addrlen++] = ']';
+			addrbuf[addrlen++] = '\0';
+			if (wordinclass(addrbuf, 'w'))
+			{
+				if (buf && !localbuf)
+					localbuf = newstr(addrbuf);
+				ret_code++;
+			}
+			i++;
+		}
+		freehostent(h);
+	}
+finish_up:
+# endif /* NETINET6 */
+	if (ret_code <= EX_OK && buf && localbuf)
+		sm_free(localbuf);
+	else if (ret_code > EX_OK && buf && localbuf)
+		*buf = localbuf;
+
+	errno = save_errno;
+	SM_SET_H_ERRNO(save_h_errno);
+	return ret_code;
+}
+#endif /* _FFR_MX_A_REC_INCLASSW || _FFR_MX_NOHOST_SKIP || _FFR_MX_NOHOST_HIPREF*/
+
 #endif /* NAMED_BIND */
