求助:asp.net 外發郵件報錯(原先EXCHANGE2003的時候並無問題)
請各位指點一二,不知道是何原因,按照網上的一些方法改代碼都沒有成功,但是公司內部的郵件發送並無任何異常,一但郵件地址是比如163或QQ有就出現異常為:"無法使用信箱。 伺服器回應為: 5.7.1 Unable to relay"
bool isuf = false;
MailMessage mail = new MailMessage();
sMailForm = "endy@kbg-cn.com";
mail.From = new MailAddress(sMailForm, "行政採購系統");
mail.To.Add("endy@kbg-cn.com");
mail.To.Add("153797659@qq.com");
mail.CC.Add(sMailForm);
string sMailTo = GetCUSTMail();
mail.Subject = "行政採購單審核通知";
mail.IsBodyHtml = true;
mail.Body = GetMailBodyL();
//"172.16.1.19", 25
SmtpClient mailSmtp = new SmtpClient();
mailSmtp.EnableSsl = true;
mailSmtp.Host = "172.16.1.19";
mailSmtp.Port = 25;
mailSmtp.Credentials = new NetworkCredential("Bpmadin", "234567", "kbg-cn.com");
try
{
if (sMailTo != "" || sMailTo != null)
{
// mailSmtp.Send(mail);
mailSmtp.Send(mail);
isuf = true;
return isuf;
}
else
{
isuf = false;
Page.ClientScript.RegisterStartupScript(GetType(), "", "alert('供應商郵件不能為空,請先維護供應商郵件聯系方式');", true);
return isuf;
}
//Page.ClientScript.RegisterStartupScript(GetType(), "", "ReturnValues();", true);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
Page.ClientScript.RegisterStartupScript(GetType(), "", "alert('操作失敗');", true);
return isuf = false;
}
------解决方案--------------------
C# code
--改下面幾句試下
--mailSmtp.EnableSsl = true;
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
mailSmtp.Credentials = new NetworkCredential("Bpmadin", "234567");
------解决方案--------------------
是不是你們的郵件服務器認證信息改了?