服务器 不能访问网站吗,不能从同一服务器访问网站

我在http://SomeDomain.com上有一个网站.当我从任何计算机访问该域时,我都可以访问该网站.然后,如果我从托管该网站的服务器转到相同的域,则将无法访问该网站.好像防火墙不会启用该连接.

我知道我可以从该服务器中访问http:// localhost以便访问该网站.

无论如何,问题是我无法从该服务器发送电子邮件,我具有以下代码来发送电子邮件:

public static void SendEmail(string toEmailAddress, string subject, string body)

{

var fromAddress = new MailAddress("sales@domainName.com", "domainName");

var toAddress = new MailAddress(toEmailAddress);

string fromPassword = "MY_PASSWORD";

var smtp = new SmtpClient

{

Host = "mail.toglcloud.com",

Port = 587,

EnableSsl = true,

DeliveryMethod = SmtpDeliveryMethod.Network,

UseDefaultCredentials = false,

Credentials = new NetworkCredential("v040\sales.domainName", fromPassword)

};

using (var message = new MailMessage(fromAddress, toAddress)

{

Subject = subject,

Body = body

})

{

ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };

smtp.Send(message);

}

}

当我从任何计算机上运行该代码(我已经尝试过5种不同的代码)时,它都能工作!但是,如果我在服务器(计算机托管网站,并且包含邮件服务器)上运行该确切代码,它将无法正常工作.我得到以下异常:

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 206.155.112.15:587 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, Int32 timeout,

Exception& exception) — End of inner exception stack trace —

我认为这与为什么找不到端点http://SomeDomain.com的原因相同

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值