【问题标题】:'System.Net.Mail.SmtpException: Failure sending mail from remote mail server'System.Net.Mail.SmtpException:从远程邮件服务器发送邮件失败
【发布时间】:2014-05-06 09:39:44
【问题描述】:

我尝试使用远程邮件服务器从 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 服务器。

【问题讨论】:

  • 可能有很多原因。您是否位于可能阻止 SMTP 请求的防火墙后面?您的地址是否正确?
  • 我认为它无法连接到您的 SMTP 服务器。可能是防火墙或防病毒软件。您需要从防火墙和防病毒软件中允许它。
  • 即使防火墙关闭,它也不能正常工作,它在本地服务器上工作正常

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


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

【讨论】:

    猜你喜欢
    • 2012-05-24
    • 1970-01-01
    • 1970-01-01
    • 2014-06-15
    • 1970-01-01
    • 2012-05-04
    • 1970-01-01
    • 2014-11-18
    • 2015-06-09
    相关资源
    最近更新 更多