如何从电子邮件地址获取SMTP服务器

如何从电子邮件地址获取SMTP服务器

本文介绍了如何从电子邮件地址获取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);


推荐答案

您可以通过以下方式找到域的SMTP服务器:托管电子邮件地址的一部分(在您的示例中为 qorosauto.com ),然后查找。

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中执行此操作并不简单,因为对此问题的回答表明:

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服务器进行通信,该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