'System.Net.Mail.SmtpException:从远程邮件服务器发送邮件失败

时间:2014-03-27 12:10:10

标签: asp.net smtp windows-server-2012 mail-server smtp-auth

我试图从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 telnet smtp服务器,但可能从本地系统telnet。

1 个答案:

答案 0 :(得分:2)

  • 您可能需要将IIS服务器的传出IP地址添加到防火墙。如果您能够,请转到http://whatismyipaddress.com/,这会告诉您出站地址。
  • 您可能需要查看您的防病毒配置 - 如果您使用McAffee,这可能有所帮助:http://digital.ni.com/public.nsf/allkb/76D1CFA7F3C047D08625719B006861B5
  • 而不是指定&#34; host&#34;在您的代码中作为SMTP服务器主机名,您可以尝试指定SMTP服务器的IP地址
  • 一旦您可以远程登录到SMTP服务器,请确保没有反垃圾邮件妨碍您的应用程序最终连接到实际的SMTP服务器