0

我尝试使用远程邮件服务器从 VPS windows 2012 和 IIS 8 服务器发送邮件,我无法发送邮件,并收到错误

send Faild - System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> 
System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time,
or established connection failed because connected host has failed to respond <Ip Address> at System.Net.Sockets.Socket.DoConnect(EndPoint 
endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6,
Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) --- End of inner exception stack 
trace --- at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket,
Socket& abortSocket6) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, GeneralAsyncDelegate asyncCallback) at     System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at     System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of 
inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at WebApplication1.Default.Page_Load(Object sender, EventArgs e) 

使用的代码

<%

Dim Email As New System.Net.Mail.MailMessage( _"emails@domain.org", "email@domain.org")
Email.Subject = "test subject"
Email.Body = "this is a test"
Dim mailClient As New System.Net.Mail.SmtpClient()
'This object stores the authentication values
 Dim basicAuthenticationInfo As _
New System.Net.NetworkCredential("username", "password")
mailClient.Host = "host"
mailClient.UseDefaultCredentials = False
mailClient.Credentials = basicAuthenticationInfo
mailClient.Send(Email)

%>

更新

无法从 vps 远程登录 smtp 服务器,但可以从本地系统远程登录 smtp 服务器。

4

1 回答 1

2
  • 您可能需要将 IIS 服务器的传出 IP 地址添加到防火墙。如果可以,请访问 http://whatismyipaddress.com/,这将告诉您您的出站地址
  • 您可能需要查看您的防病毒配置 - 如果您使用的是 McAffee,这可能会有所帮助:http ://digital.ni.com/public.nsf/allkb/76D1CFA7F3C047D08625719B006861B5
  • 而不是在您的代码中指定“主机”作为 SMTP 服务器主机名,您可以尝试指定您的 SMTP 服务器的 IP 地址
  • 同样,一旦您可以远程登录到 SMTP 服务器,请确保没有反垃圾邮件阻止您的应用程序最终连接到实际的 SMTP 服务器
于 2014-04-28T06:53:41.480 回答