Finding the MX Record using C#?(使用 C# 查找 MX 记录?)
问题描述
如何在 C# 中找到邮件服务器的 MX 记录?
How can I find the MX record for a mail server in C#?
推荐答案
可以使用Robert 和 RPK 获取给定域的 MX 记录.
You can use the answer of Robert and RPK to get the MX record of a given domain.
但是您需要一个 DNS 服务器来完成这项工作.如果你想检测你的代码执行所在机器的DNS服务器,你可以使用下面的.
But you'll need a DNS server to do the job. If you want to detect the DNS server of the machine where your code is executed, you can use the following.
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in adapters)
{
IPInterfaceProperties properties = adapter.GetIPProperties();
if (properties.DnsAddresses.Count > 0)
foreach (IPAddress ipAddress in properties.DnsAddresses)
dnsServers.Add(ipAddress.ToString(), 53);
}
有一个完整解决方案(或在github here) 如果您不想重写所有内容,它将完成整个工作.寻找 GetMxRecords 静态方法.
There is a complete solution (or at github here) that will do the whole job if you don't want to rewrite everything. Look for GetMxRecords static method.
这篇关于使用 C# 查找 MX 记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 C# 查找 MX 记录?
基础教程推荐
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
