SPF Test: checks if an Internet domain has an SPF record

If you have information, script, utility, or idea that can be useful for HostMonitor community, you welcome to share information in this forum.
Post Reply
terje
Posts: 88
Joined: Mon Jul 25, 2005 7:45 pm
Location: Sydney

SPF Test: checks if an Internet domain has an SPF record

Post by terje »

We have created a script for testing whether a domain has an SPF record.

An SPF record identifies which servers are authorised to send email with the relevant domain name in the MAIL FROM:<xxx@domain.com> address part of the SMTP session. For details see http://spf.pobox.com

The script has been tested on a WINDOWS-2003 server running HOSTMONITOR v5.6beta.

The Hint for the script is: Params: <domain>
The start command for this script is: cmd /c %Script% %Params%

The body of the script is:-
@echo off
REM query domain and return a SPF record status

if "%1"=="" goto NOPARAMS

setlocal

set DNS=%1
set FILE=%temp%\~spfcheck.%1.tmp
del %FILE%

nslookup -q=txt %DNS% > %FILE% 2>&1

FOR /F "tokens=*" %%B IN ('type %FILE% ^| FIND /I "***"') DO CALL :NODOMAIN %%B

FOR /F "tokens=*" %%B IN ('type %FILE% ^| FIND /I "v=spf"') DO CALL :OKRECORD %%B

echo ScriptRes:Bad:No Record
goto ALLDONE


:NODOMAIN
echo ScriptRes:Unknown:domain not found
goto ALLDONE

:OKRECORD
echo ScriptRes:Ok:%1
goto ALLDONE

:NOPARAMS
echo ScriptRes:Unknown:not enough parameters
goto ALLDONE

:ALLDONE
del %FILE%
exit
An example of a domain with an SPF record that you can use for testing is: google.com.au
Post Reply