My website is on a Hostgator shared host, and I need to set up SPF for my email so my outgoing emails won't get bounced. So, I have to add a TXT record to the DNS for my domain, listing all possible senders of my domain's email. Shouldn't be a big deal, right?
Unfortunately, I found that Hostgator routes outgoing email from shared hosts through multiple email gateway servers, all with domains in the format
gatewayXX.websitewelcome.com for some two-digit XX. So, I started sending test emails to myself, adding new servers as I found them. After finding six of them, I had the following SPF record...
v=spf1 +a +mx +ip4:184.108.40.206 +a:gateway33.websitewelcome.com +a:gateway26.websitewelcome.com +a:gateway20.websitewelcome.com +a:gateway24.websitewelcome.com +a:gateway22.websitewelcome.com +a:gateway36.websitewelcome.com ~all
... and kept finding more.
I finally wrote a script that went through the one hundred possible domains in the above format, and found that 28 of them existed, mapping to a total of 705 IP addresses. Nope: can't have that many domains in my SPF record, as it would be too many DNS lookups as well as just too many characters.
How do I accomplish this? Must I scan the 705 IP addresses and figure out what CIDR-notated networks cover them all? Am I then giving permission for anyone hosted at Hostgator to spoof my domain name in their outgoing mail? Is there a completely different approach I should take to this? Or should I be looking for a different hosting setup with a small number of publicly visible outgoing email servers?