你的位置:首页 > ASP.net教程

[ASP.net教程]关于发邮件的服务器的端口号


 

今天搞一个发邮件的小功能,一切参数设置好,就是服务器没响应。

一开始怀疑是邮件服务器设置不对,邮件服务器和outlook中找到的是一致的。

怀疑端口号25不对。大部分资料都说是25呀。

。。。

后来找到这个网页,说

Usually an outgoing server employs port 25: it's the default SMTP port. However, some IPs deny its use because of the massive spam and malware traffic by which is affected. This issue is raised in particular when you need to switch to another ISP – for instance, when you're travelling and connecting to a new provider. In this case you can try to use port 587 or port 465 to avoid the block. 

More in detail: port 587 is supported by almost every outgoing SMTP server and it's useful for unencrypted or TLS connections; while port 465 is the right choice if you need to connect via SSL.

摘自:http://www.serversmtp.com/en/port-for-smtp

即:25是默认端口,可能因为spam等原因用不了,这时可以考虑587.一般对于非加密的请求587都能用。

修改端口号为587后,果然OK。

 

 

附:

C#开发邮件客户端使用SmtpClient。

使用原理:需要设置邮件服务器地址,及端口号。