The TXT records inside DNS have become very popular, so much even that large institutions, like e.g. princeton.edu, issue 5 or more : [hubble:root]:(~/src/libspf-1.0.0-RC6/src/spfqtool)# ./spfqtool -i 192.168.2.10 -s stock@princeton.edu -h stokkie.net Answer Data 1: (Contact to report abuse, attacks: abuse@princeton.edu, or phone +1-609-258-4357 and ask for the Security and Policy Advisor ) len: 124 Answer Data 2: (v=spf1 ip4:128.112.128.212 ip4:128.112.128.213 ip4:128.112.128.214 ip4:128.112.128.215 ip4:128.112.128.216 ip4:128.112.129.74 mx ?all ) len: 134 Answer Data 3: (Contact for general computing help: Office of Information Technology Support and Operations Center: helpdesk@princeton.edu, phone +1-609-258-4357 ) len: 146 Answer Data 4: (MS=ms98806852 ) len: 14 Answer Data 5: (Princeton University; Princeton, New Jersey, U.S.A. ) len: 52 Answer Data 6: (google-site-verification=9SPyuHTDpGLTj4BA6qoL87mlLTsvqWTWPFPJCKHXUAA ) len: 69 SPF short result: neutral SPF verbose result: policy result: (neutral) from rule (?all) RFC2822 header: Received-SPF: neutral (stokkie.net: domain of stock@princeton.edu is neutral about designating 192.168.2.10 as permitted sender) [hubble:root]:(~/src/libspf-1.0.0-RC6/src/spfqtool)# This patch handles multiple TXT records and moves, inside the result of DNS_Query (rr_data), the TXT record holding "v=spf1" up front as the first obtained TXT record. So in the above example "Answer Data 2" is put in front and the remaining TXT records are appended to "Answer Data 2". So rr_data becomes : "Answer Data 2","Answer Data 1","Answer Data 3", "Answer Data 4","Answer Data 5","Answer Data 6" which combines to : rr_data = "v=spf1 ip4:128.112.128.212 ip4:128.112.128.213 ip4:128.112.128.214 ip4:128.112.128.215 ip4:128.112.128.216 ip4:128.112.129.74 mx ?all Contact to report abuse, attacks: abuse@princeton.edu, or phone +1-609-258-4357 and ask for the Security and Policy Advisor Contact for general computing help: Office of Information Technology Support and Operations Center: helpdesk@princeton.edu, phone +1-609-258-4357 MS=ms98806852 Princeton University; Princeton, New Jersey, U.S.A. google-site-verification=9SPyuHTDpGLTj4BA6qoL87mlLTsvqWTWPFPJCKHXUAA " The debugging feature above can be activated inside libspf-1.0.0-RC6/src/libspf/dns.c at line 626 by changing : for (j=1; j<= ancount; j++) xprintf("Answer Data %i: (%s) len: %i\n", j, rr_record[j], strlen(rr_record[j])); into for (j=1; j<= ancount; j++) fprintf(stdout, "Answer Data %i: (%s) len: %i\n", j, rr_record[j], strlen(rr_record[j])); Robert M. Stockmann, stock@stokkie.net Sat Dec 3 23:30:32 CET 2011