This directory gives a test program for the DNS code used in Blackmail.
The code uses the 'gethostbyname' call to determine if an email address
host part is valid.
If you find Blackmail rejects valid address because of the DNS checks, then
try this out and report you findings.
If you get the wrong reply or a different h_errno you can check in your
/usr/include/netdb.h and see what code should be returned on your system
(see end of document.)

To do the checks:

	make

Then try some addresses

e.g.

> ./dns-test csv.warwick.ac.uk
About to execute gethostbyname("csv.warwick.ac.uk")
h_errno = 4
dns OK (NO_DATA)

> ./dns-test netbsd.org
About to execute gethostbyname("netbsd.org")
h_errno = 4
dns OK (NO_DATA)

> ./dns-test www.linux.org
About to execute gethostbyname("www.linux.org")
dns OK

> ./dns-test public.com
About to execute gethostbyname("public.com")
h_errno = 1
dns (HOST_NOT_FOUND)

The first two are MX records only, the third is an actual host, the fourth
is that wretched fake domain we've seen so many times...

Some more detail:

The relevant portion of my netdb.h looks like this

    #define NETDB_INTERNAL -1 /* see errno */
    #define NETDB_SUCCESS   0 /* no problem */
    #define HOST_NOT_FOUND  1 /* Authoritative Answer Host not found */
    #define TRY_AGAIN       2 /* Non-Authoritive Host not found, or SERVERFAIL */
    #define NO_RECOVERY     3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */#define NO_DATA         4 /* Valid name, no data record of requested type */
    #define NO_DATA         4 /* Valid name, no data record of requested type */
    #define NO_ADDRESS      NO_DATA         /* no address, look for MX record */
 
Thus the MX sites freebsd.org and csv.warwick.ac.uk should both return
h_errno == 4  on my system. If they return 'HOST_NOT_FOUND' on your
system, then don't use the DNS checks in Blackmail.


jsm 29 Jan 1998
