Re: Tip: Restricting mail reception using a remote service's SPF records

by Barney Desmondon 2009-06-25T09:54:48+00:00
> The following is "concept"; I don't have the script yet ready, but
> it'll be easy to write with your favorite scripting language:
>
> -------
> 1. get your remote sender's current SPF record:
>
> dig yourremotesender.com txt =C2=A0> tempfile
>
> 2. parse the result in tempfile with regex:
>
> /.*?ANSWER\sSECTION:.*?yourremotesender\.com*.\s+?\d+?\s+?IN\s+?TXT\s+?"v=
=3Dspf1\s+?([^)]+?)\s+?.all"/

The implementation seems a little fragile, but the concept should be
workable. On dig (at least the versions I've used), you can use +short
for parseable output. Example:
dig +short example.com TXT | grep 'v=3Dspf1' | egrep -o 'ip4:[0-9./]+' |
sed 's/^ip4://' | sed 's/$/ OK/' > tempfile
Something like that, anyway.

Conversations: Tip: Restricting mail reception using a remote service's SPF records