问题描述
我创建了一个asp.net网站,其中包含一个向帐户发送电子邮件的联系表单。它在我的机器上本地工作,但当我将它部署到Godaddy时,它不起作用并引发异常:
连接尝试失败,因为连接方没有一段时间后正确响应,或者建立的连接失败,因为连接的主机无法响应198.37.144.225:587
Godaddy说它必须在我的最后。
我已经阅读了谷歌提供的每一篇文章,并多次联系Godaddy寻求支持,但无济于事。
有没有人有任何建议,链接或示例他们目前在godaddy上托管的ASP.Net 4.5 C#网站上工作?
这是我的拥有:
I have created an asp.net site that has a contact form that sends an email to an account. It works locally on my machine, but when I deploy it to Godaddy, it does not work and throws an exception:
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 198.37.144.225:587
Godaddy says it must be on my end.
I have read just about every article that google offers and have contacted Godaddy several times for support with no avail.
Does anyone have any advice, links, or examples they currently have working on an ASP.Net 4.5 C# site hosted on godaddy?
Here is what I have:
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtpout.secureserver.net";
smtp.Port = 465;
smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "password");
MailMessage mailMsg = new MailMessage();
mailMsg.From = new MailAddress("[email protected]");
mailMsg.To.Add(new MailAddress("[email protected]"));
mailMsg.ReplyTo = new MailAddress("[email protected]");
mailMsg.Subject = "New contact message from site";
mailMsg.Body = string.Format("Name: {0}<br /><br /> Phone number: {1}<br /><br /> Email: {2}<br /><br />" +
"Subject:{3}", name, phone ?? "None provided", from, subject);
mailMsg.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
smtp.Send(mailMsg);
我也试过:
I have also tried:
SmtpClient smtp = new SmtpClient();
smtp.Host = "relay-hosting.secureserver.net";
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
MailMessage mailMsg = new MailMessage();
mailMsg.From = new MailAddress("[email protected]");
mailMsg.To.Add(new MailAddress("[email protected]"));
mailMsg.ReplyTo = new MailAddress("[email protected]");
mailMsg.Subject = "New contact message from site";
mailMsg.Body = string.Format("Name: {0}<br /><br /> Phone number: {1}<br /><br /> Email: {2}<br /><br />" +
"Subject:{3}", name, phone ?? "None provided", from, subject);
mailMsg.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
smtp.Send(mailMsg);
推荐答案
SmtpClient client = new SmtpClient(host);
NetworkCredential credentials = new NetworkCredential(user, password);
client.UseDefaultCredentials = false;
client.Credentials = credentials;
client.Send(message);
我的主机是smtpout.europe.secureserver.net,端口是3535
Valery。
my host is smtpout.europe.secureserver.net and the port is 3535
Valery.
这篇关于如何从Godaddy托管的asp.net网站发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!