2014-03-27 162 views
0

我试图从VPS窗口发送邮件2012 &使用远程邮件服务器的IIS 8服务器,我无法发送邮件,并且出现错误'System.Net.Mail.SmtpException:从远程邮件服务器发送邮件失败

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(_"[email protected]", "[email protected]") 
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) 

%> 

更新

无法远程登录SMTP服务器从VPS,但是从本地系统的可能。

+0

可能有许多原因这个。你是否在可能阻止SMTP请求的防火墙之后?你的地址是否正确? –

+1

我认为它无法连接到您的SMTP服务器。可能是防火墙或防病毒软件。您需要允许来自防火墙和防病毒软件。 –

+0

即使防火墙关闭,它不工作,它从本地服务器正常工作 – sarath009

回答

1
  • 您可能需要将您的IIS服务器的传出IP地址添加到防火墙。如果可以,请转至http://whatismyipaddress.com/,这会告诉您您的出站地址。
  • 你可能需要看看你的防病毒配置 - 如果你正在使用MCAFFEE这可能会帮助:http://digital.ni.com/public.nsf/allkb/76D1CFA7F3C047D08625719B006861B5
  • ,而不是在你的代码中指定的“主机”作为SMTP服务器的主机名,你可以尝试指定的IP地址您的SMTP服务器
  • 也曾您可以远程登录到SMTP服务器,请确保没有防垃圾邮件越来越在从最后连接到实际的SMTP服务器停止你的应用程序的方式
相关问题