简体   繁体   English

如何从电子邮件地址获取SMTP主机名?

[英]How can I get the SMTP host name from email address?

I was working on an application which would send emails automatically at specific time intervals to a valid email. 我正在开发一个应用程序,它将在特定时间间隔自动将电子邮件发送到有效电子邮件。 Searching through the internet I found that most of the codes use the existing email accounts such as gmail.com to send email by logging in as an SMTP client. 通过Internet搜索,我发现大多数代码都使用现有的电子邮件帐户(例如gmail.com)通过以SMTP客户端身份登录来发送电子邮件。 But my problem is that I won't be knowing the smtp server name of the users email(since the user is not generally aware of these things though he will be knowing the login/passoword). 但是我的问题是,我将不知道用户电子邮件的smtp服务器名称(因为尽管用户会知道登录名/密码,但用户通常并不了解这些东西)。 For example, 例如,

someone@gmail.com should give smtp.gmail.com and port number (465) someone@gmail.com应提供smtp.gmail.com和端口号(465)

someone@nextek.net should give mail.nextek.net and port number (?) someone@nextek.net应该提供mail.nextek.net和端口号(?)

someone@screaming.Net smtp.tiscali.co.uk and port number (?) someone@screaming.Net smtp.tiscali.co.uk和端口号(?)

I got the MX records using the domain name of the email address, but I realized that it actually gives the available incoming SMTP server names. 我使用电子邮件地址的域名获得了MX记录,但是我意识到它实际上提供了可用的传入SMTP服务器名称。

For example gmail.com would give gmail-smtp-in.l.google.com along with four other server name if I ping using nslookup in command prompt. 例如,如果我在命令提示符下使用nslookup进行ping操作,则gmail.com将提供gmail-smtp-in.l.google.com以及其他四个服务器名称。

Also what is the advantage of sending email by using an existing SMTP supporting email than sending directly by looking up the email server name through dns? 与通过dns查找电子邮件服务器名称直接发送相比,使用现有的SMTP支持电子邮件发送电子邮件的优势是什么? Or is it not possible? 还是不可能?

Correct me if I am wrong, since I am not much familiar with the protocols. 如果我错了,请指正我,因为我对协议不太熟悉。

If you're not familiar with the protocols, it doesn't make sense for you to try to implement the protocol. 如果您不熟悉该协议,那么尝试实施该协议就没有任何意义。

Generally, an application like yours doesn't need to worry about the details of the SMTP protocol. 通常,像您这样的应用程序无需担心SMTP协议的细节。 You would use an existing SMTP client library for your platform (I'm sure there is one for .NET you can use), and connect to an MTA ( your MTA, not the recipient's), give it the email to send, and you're done. 您将为平台使用现有的SMTP客户端库(我确定可以使用.NET的一个),然后连接到MTA( 您的 MTA,而不是收件人的MTA),并给它发送电子邮件,然后'重做。 The MTA will take care of all the SMTP protocol details of figuring out how to get the email to the recipient. MTA将处理所有SMTP协议细节,以弄清楚如何将电子邮件发送给收件人。

Sending email is very similar to dropping a letter in the post box on the corner, and letting the post office figure out how to deliver it. 发送电子邮件非常类似于在角落的信箱中放一封信,然后让邮局弄清楚如何发送。 You don't need to know which vehicle to put it on, or where the recipient's local post office distribution centre is, or any of those details. 您不需要知道要放哪辆车,收件人的本地邮局配送中心在哪里,也不需要任何这些细节。

You may choose to set up your own MTA using something like Postfix , or you can send email through your own Gmail account (of course you'll need a Gmail account and password before Gmail will let you do that). 您可以选择使用Postfix之类的内容来设置自己的MTA,也可以通过自己的Gmail帐户发送电子邮件(当然,在Gmail允许您这样做之前,您需要一个Gmail帐户和密码)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM