场景:
在我的Web应用程序(ASP.NET MVC + C#+ JS ...)中,我输入了电子邮件地址。在大多数情况下,是否有任何方法可以获取其SMTP服务器名称?
例如foo@gmail.com的smtp.gmail.com
答案 0 :(得分:1)
听起来您在谈论MX记录。当您要将电子邮件发送到gmail.com电子邮件地址时,可以查找Mail Exchange(MX)记录:
$ host -t mx gmail.com
gmail.com mail is handled by 20 alt2.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 30 alt3.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 40 alt4.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 5 gmail-smtp-in.l.google.com.
gmail.com mail is handled by 10 alt1.gmail-smtp-in.l.google.com.
通常,第一个尝试尝试的主机是距离最短的主机。在这种情况下,它是gmail-smtp-in.l.google.com,距离为5。
$ telnet gmail-smtp-msa.l.google.com 25
Trying 74.125.197.109...
Connected to gmail-smtp-msa.l.google.com.
Escape character is '^]'.
220 smtp.gmail.com ESMTP w63-v6sm8014513pfa.135 - gsmtp
ehlo there
250-smtp.gmail.com at your service, [4.78.245.197]
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
quit
221 2.0.0 closing connection w63-v6sm8014513pfa.135 - gsmtp
Connection closed by foreign host.