2014-03-27 197 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服務器停止你的應用程序的方式
相關問題