从域中获取SPF记录 [英] Get SPF records from a Domain
问题描述
检查域中SPF记录的方法是什么?
有一个网站可以在我的网站上手动使用-库(也可以作为 NuGet包使用).
安装软件包后,我设法使用以下代码执行SPF检查:
var spfValidator = new ARSoft.Tools.Net.Spf.SpfValidator();var mailIpAddress = IPAddress.Parse("X.X.X.X");var domain ="example.com";var senderAddress ="sender@example.com";ARSoft.Tools.Net.Spf.SpfQualifier结果=spfValidator.CheckHost(mailIpAddress,域,senderAddress);
What are the ways to Check SPF records on a domain?
There is a website where i can do it manually using - http://www.mxtoolbox.com/SuperTool.aspx
How can i do it via ASP.NET and C#? Basically i want to verify/check SPF records on a domain if its supporting out own mail web server.
I have the same problem, and managed to find two three solutions:
The nslookup
solution
You can get the SPF by typing the following command in the command line:
nslookup -type=TXT <hostname>
You can automate this in C# using System.Diagonstics.Process
, as described in this blog post.
The DNS.NET Resolver project
I found this CodeProject article about DNS resolution. It comes with demo project. I ran the project and got the following result for stackexchange.com
:
Note: Make sure that the QType field is set to TXT before you press the Send button
The section highlighted in yellow represents the SPF record. I haven't yet dug into the code to see how it's done, but this seems like a good alternative to the nslookup
solution above.
[Update] The ARSoft.Tools.Net project
If all you need to do is check whether a domain supports a mail server, you can use the ARSoft.Tools.Net library (also available as a NuGet Package).
After installing the package, I managed to perform the SPF check with this code:
var spfValidator = new ARSoft.Tools.Net.Spf.SpfValidator();
var mailIpAddress = IPAddress.Parse("X.X.X.X");
var domain = "example.com";
var senderAddress = "sender@example.com";
ARSoft.Tools.Net.Spf.SpfQualifier result =
spfValidator.CheckHost(mailIpAddress, domain, senderAddress);
这篇关于从域中获取SPF记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!