从电子邮件地址获取SMTP服务器 [英] Get SMTP server from email address

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

问题描述



我正在用C#和.NET 4编写电子邮件发送程序.
用户提供他的电子邮件地址,以及
中的电子邮件地址 收件人.

如何从用户的电子邮件地址检索SMTP服务器?

例如:
用户给出"user7712279@gmail.com".而且我需要找到SMTP服务器"smtp.gmail.com".但是对于Yahoo,Hotmail和其他电子邮件服务,它也必须起作用.我该怎么办?

在此先感谢您.

Hi,

I''m programming a email sending program in C# and .NET 4.
The user gives his email address, and also the email address from the
reciever.

How can I retrieve the SMTP server from the users email address?

For example:
The user gives "user7712279@gmail.com". And I need to find the SMTP server "smtp.gmail.com". But for Yahoo, Hotmail, and other email services, it must work also. How can I do that?

Thanks in advance.

推荐答案

您不能这样做.您可以查找域的MX记录,但这就是入站邮件交换器,并且很简单,它将不接受来自程序的邮件.如果这样做的话,世界上每个垃圾邮件发送者都会按照您的要求去做.邮件服务器(如GMail,Yahoo等)希望在进行合法查找之前先进行反向查找和正确配置的服务器.即使在家庭连接上设置SMTP服务器进行中继,仍然有可能使您的邮件退回.

正如其他人在评论中指出的那样,您必须通过完全合格的SMTP服务器发送电子邮件.该服务器将找出远程邮件系统,并将完成所有肮脏的工作来传递邮件.服务器(主机),用户ID和密码都是最终用户提供您的应用程序所需的设置.

或者,有些第三方库(如兑换"库)将使用Windows计算机上的内置Outlook(或MS Mail)设置.如果要以当前用户身份发送邮件,并且该用户在Windows中已设置电子邮件,这将非常方便.其中一些API在Win 8中可能已更改...我不知道...但是我在Win 7中使用了Redemption库,这使其他所有功能都无法使用.

并不是很关键,但是SMTP上有很多教程,描述了它是如何工作的以及通常如何发送和接收邮件.在继续进行此操作之前,您可能应该仔细阅读所有幕后内容.除非您遵守规则,否则您的邮件将被退回,您将不知道为什么.
You can''t do this. You can lookup the MX record for the domain but that is the inbound mail exchanger and, quite simply, it won''t accept mail from your program. If it did, every spammer in the world would do what you are asking to do. Mail servers (like GMail, Yahoo, etc) want things like reverse lookups and properly configured servers before they will consider them legit. Even setting up an SMTP server on your home connection to relay through is still likely to get your messages bounced.

As the others have pointed out in the comments, you must send e-mail through a fully-qualified SMTP server. That server will figure out the remote mail system and will do all of the dirty work to get the message delivered. The server (host), the userID, and password would all be settings the end user would need to provide your application.

Alternately, there are some third party libraries, like the Redemption library, that will use the built-in Outlook (or MS Mail) settings on a Windows machine. This is convenient if you want to send mail as the current user and the user has e-mail setup in Windows. Some of these APIs may have changed in Win 8... I don''t know... but I have used the Redemption library through Win 7 and it kicks the crap out of everything else.

And not to be critical, but there are lots of tutorials out there on SMTP describing how it works and how mail, in general, is sent and received. All of the behind-the-scenes stuff you should probably brush up on before going further on this. Unless you follow the rules, your messages will get bounced and you won''t know why.


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆