-2
下面的代碼在使用本地主機進行調試時工作正常,但在我發佈到Web服務器後無法正常工作。MailMessage smtpClient在發佈後不工作
protected void SendMail()
{
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress("[email protected]");
mailMessage.To.Add("[email protected]");
mailMessage.Subject = ddlSubject.Text;
mailMessage.Body = "<b>Sender Title: </b> " + ddlTitle.SelectedItem.Text + "<br/>"
+ "<b>Sender First Name: </b> " + txtFName.Text + "<br/>"
+ "<b>Sender Last Name: </b> " + txtLName.Text + "<br/>"
+ "<b>Sender Email: </b> " + txtEmail.Text + "<br/>"
+ "<b>Sender Phone: </b> " + txtPhone.Text + "<br/>"
+ "<b>Sender Address: </b> " + txtAddress.Text + "<br/>"
+ "<b>Sender Suburb: </b> " + ddlSuburbs.SelectedItem.Text + "<br/>"
+ "<b>Sender Message: </b> " + contactMessage.InnerText + "<br/>";
mailMessage.IsBodyHtml = true;
SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
smtpClient.Credentials = new System.Net.NetworkCredential("[email protected]", "xxxxxx");
smtpClient.EnableSsl = true;
smtpClient.Send(mailMessage);
lblConfirmation.Text = "Thank you " + ddlTitle.SelectedItem.Text + " " + txtFName.Text.ToUpper() + " " + txtLName.Text.ToUpper() + " for contacting us. We will try to get back to you ASAP";
}
注意的網站使用SSL。
您是否檢查過是否有任何防火牆規則或生產服務器上是否有代理? – BDH
我正在使用goDaddy託管服務 – Deeyo
也許您應該問他們是否阻止使用該端口的傳出流量。 – BDH