【问题标题】:Mail not sending from web hosting server邮件未从网络托管服务器发送
【发布时间】:2016-12-28 12:25:10
【问题描述】:

我在我的网站上有联系表格。使用 GoDaddy 进行 Windows 托管。当我在本地主机中测试联系人时,它可以正常工作并发送邮件,但在托管时会出现异常。

System.Net.Mail.SmtpException:发送邮件失败。 ---> System.Net.WebException:无法连接到远程服务器 ---> System.Net.Sockets.SocketException:试图以访问权限 74.125.130.108:587 禁止的方式访问套接字在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) 在 System.Net.ServicePoint.ConnectSocketInternal (Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) --- 内部异常堆栈跟踪结束 --- 在 System.Net.PooledStream.Activate(Object owningObject 的 System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6) , 布尔异步, GeneralAsyncDelegate asyncCallback) 在 System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) 在 System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate e asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpClient.GetConnection() at System.Net .Mail.SmtpClient.Send(MailMessage message) --- 内部异常堆栈跟踪结束 --- 在 System.Net.Mail.SmtpClient.Send(MailMessage message) 在 DynamicPage.sendInquiry_Click(Object sender, EventArgs e) 在 G: \PleskVhosts\brandstik.in\httpdocs\DynamicPage.aspx.vb:173 行

try {
    MailMessage mail = new MailMessage();
    SmtpClient SmtpServer = new SmtpClient();
    mail.To.Add("abc@gmail.com");
    mail.From = new MailAddress(inquiryEmail.Text);
    mail.Subject = "Quote Request For " + quoteID.Text;
    mail.Body = "New Quote request from customer<br /><br/>Customer Name - '" + inquiryName.Text + "' <br />Customer Email - '" + inquiryEmail.Text + "'<br />Customer Contact - '" + inquiryNumber.Text + "'<br />Comment - '" + inquiryMessage.Text + "'";
    mail.IsBodyHtml = true;
    SmtpServer.Port = 587;
    SmtpServer.Credentials = new System.Net.NetworkCredential("xyz@doamain.com", "1234567890");
    SmtpServer.Host = "smtp.gmail.com";
    SmtpServer.EnableSsl = true;
    SmtpServer.Send(mail);
    Response.Write("Sent");
} catch (Exception ex) {
    //Response.Write("<script language='javascript'>alert('Your SMTP Server needs to get configured to contact form work.');</script>")
    Response.Write(ex);
}

【问题讨论】:

标签: c# asp.net vb.net sockets email


【解决方案1】:

似乎他们不允许。您需要使用 GoDaddys 电子邮件中继服务器。在此处查看手册:https://www.godaddy.com/help/send-email-using-systemnetmail-19291

【讨论】:

  • SmtpServer.Host = "smtp.gmail.com" 你的意思是 GoDaddy 不允许这样做?
  • 对,你必须在那里使用 relay-hosting.secureserver.net
  • 你确定吗?如果我必须使用 gmail 发送电子邮件,那么我也需要使用 relay-hosting.secureserver.net 吗?
  • @SUN -- 您或许可以将他们的中继服务器与 Gmail 回信地址一起使用,但某些收件人的邮件可能会延迟或被阻止。理想情况下,您希望使用经过身份验证的帐户进行发送。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-01-07
  • 2016-12-07
  • 1970-01-01
  • 2014-10-26
  • 2013-09-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多