本文介绍了如何从电子邮件地址获取 SMTP 服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过特殊的邮箱账户自动发送邮件,但现在我只知道邮箱地址:[email protected] 和密码.那么你知道如何获取 SMTP 服务器吗?下面是我的 C# 代码:

I want to send mail automatically by special email account, but now, I only know the email address: [email protected] , and the password. so do you know how to get the SMTP server. below is my C# code:

        SmtpClient client = new SmtpClient();

        client.Host = "What is the SMTP Server, I want to get from email address, can you help me";
        string account = "[email protected]";
        string password = "Qoros111";

        client.Port = 587;
        client.EnableSsl = true;
        client.Timeout = 100000;

        client.DeliveryMethod = SmtpDeliveryMethod.Network;
        client.UseDefaultCredentials = false;
        client.Credentials = new System.Net.NetworkCredential(account, password);

推荐答案

您通过获取电子邮件地址的主机部分(在您的示例中为 qorosauto.com)找到域的 SMTP 服务器,并且查找 MX 记录 .

You find the SMTP server of a domain by taking the host part of the email address (qorosauto.com in your example) and looking up the MX record for it.

$ dig +short mx qorosauto.com
10 euq2.qorosauto.com.
5 euq1.qorosauto.com.

主机名前的数字表示偏好 - 在这种情况下,euq1.qorosauto.com 是要连接的首选服务器.

The number before the hostname indicate preference - in this case euq1.qorosauto.com is the preferred server to connect to.

在 .Net 中执行此操作并不简单,因为此问题的答案表明:如何使用 System.Net.DNS 获取 dns 名称的 mx 记录?

Doing this in .Net is not straight-forward, as the answer to this question indicates: How to get mx records for a dns name with System.Net.DNS?

更糟糕的是,许多 ISP 会在防火墙中过滤您的连接,并且不允许您与除 ISP 之外的任何 SMTP 服务器通信,而后者又会将邮件转发给收件人.

To add to the problems, many ISPs will filter your connection in the firewall and won't let you talk to any SMTP server except the ISPs one, which in turn will relay the mail to the recipient.

基本上,您想使用您的 ISP 或组织的 SMTP 服务器 - 而不是收件人的 MX.

Essentially, you want to use your ISPs or organizations SMTP server - not the recipients MX.

这篇关于如何从电子邮件地址获取 SMTP 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 01:55