我从我的应用程序发送电子邮件时收到错误消息。我与我的托管公司核对并获得了正确的邮件服务器设置,但我仍然收到错误消息。有什么建议么?堆栈跟踪和代码如下。
[SocketException (0x274d): No connection could be made because the target machine actively refused it 68.178.232.62:25]
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +251
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +279
[WebException: Unable to connect to the remote server]
System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) +6136880
System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) +314
System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) +21
System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) +322
System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) +146
System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint) +222
System.Net.Mail.SmtpClient.GetConnection() +50
System.Net.Mail.SmtpClient.Send(MailMessage message) +1496
[SmtpException: Failure sending mail.]
System.Net.Mail.SmtpClient.Send(MailMessage message) +1829
Lostpass.EmailUser(User user) +713
Lostpass.uxUserInfoSubmit_Click(Object sender, EventArgs e) +446
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
<mailSettings>
<smtp deliveryMethod="Network" from="support@<domain>.com">
<network host="relay-hosting.secureserver.net" port="25" defaultCredentials="true"/>
</smtp>
</mailSettings>
void EmailUser(User user)
{
user.ChangePasswordID = Guid.NewGuid();
user.Save();
MailMessage email = new MailMessage();
email.To.Add(new MailAddress(uxEmail.Text));
email.IsBodyHtml = true;
email.From = new MailAddress(Settings.LostPasswordEmailFrom);
email.Subject = Settings.LostPasswordSubject;
//email.Subject = "your new password";
email.Body = EmailTemplateService.HtmlMessageBody(EmailTemplates.MembershipPasswordRecovery, new { Body = Settings.LostPasswordText, BeginRequired = "", EndRequired = "", UserName = user.Name, GUID = user.ChangePasswordID.ToString() });
//email.Body = "your new password is: password";
SmtpClient client = new SmtpClient();
//try
//{
client.Send(email);
//}
//catch
//{ Exception ex; }
uxSuccessPH.Visible = true;
uxQuestionPanel.Visible = false;
uxUserInfoPanel.Visible = false;
uxUserNameLabelSuccess.Text = uxEmail.Text;
}