How to get the SMTP server from email address

2019-03-06 10:49发布

I want to send mail automatically by special email account, but now, I only know the email address: tsp.monitor@qorosauto.com , 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 = "tsp.monitor@qorosauto.com";
        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);

标签: c# .net email smtp
4条回答
劫难
2楼-- · 2019-03-06 11:03

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.

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

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?

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.

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

查看更多
The star\"
3楼-- · 2019-03-06 11:03

Trial and error might get you there..

  • mail.quorosauto.com
  • smtp.quorosauto.com
  • www.quorosauto.com
  • smtp.gmail.com

If you've exausted every possibility you'll need to provide your own SMTP server. There are a few freebie servers:

http://freesmtpservers.com/

However if you are doing this professionally you probably want to use the SMTP server of your organization so you probably want to ask your boss or a colleague.

查看更多
做自己的国王
4楼-- · 2019-03-06 11:06

To find out the responsible mail server you have to ask the DNS. By using the web for example go to this nslookup page.

Normally you start at the domain server of your provider, but you can also start with a root-server (e.g. 198.41.0.4) and ask for the domain google.com and the query type MX - Mail exchange.

You'll get back a list of responsible dns server. Simply pick one out of the list (e.g. 192.26.92.30) and send the same query again to this server. Rerun this sequence till you'll get a list of type MX. Simply pick one address out of this list (maybe the first, maybe the one with the lost value in preference) and use this to establish your smtp connection.

That's the way how every mail server does its work. Now it is up to you to implement that into your application. ;-)

查看更多
干净又极端
5楼-- · 2019-03-06 11:08

You may try mail.orosauto.com or smtp.orosauto.com. Login to you domain account and check mail settings. hopefully you can find the mail server details over there.

查看更多
登录 后发表回答