0
我想通過c#代碼發送郵件,我收到以下異常。 The SMTP server requires a secure connection or the client was not authenticated
。服務器響應是:5.5.1身份驗證必需。此代碼工作正常,如果我使用我的個人gmail smtp
設置發送郵件,但當我使用客戶端smptp設置它給我這個異常。應用程序託管在美國服務器上。SMTP服務器需要安全連接或客戶端未通過身份驗證。發送郵件的例外
我不知道我在做什麼錯誤的PLZ幫助。
public static void sendBulkMail()
{
DataSet _ds = new DataSet();
SMTPBAL smtpbl = new SMTPBAL(0);
smtpbl.LoadAll(_ds);
string server = _ds.Tables[smtpbl.SqlEntityX].Rows[0]["SMTPX"].ToString();
int smtpPort = WebHelper.Cast(_ds.Tables[smtpbl.SqlEntityX].Rows[0]["smtpPort"].ToString(), 0);
string From = _ds.Tables[smtpbl.SqlEntityX].Rows[0]["Email"].ToString();
string User = _ds.Tables[smtpbl.SqlEntityX].Rows[0]["User"].ToString();
string Password = _ds.Tables[smtpbl.SqlEntityX].Rows[0]["Password"].ToString();
string sDisclaimer = _ds.Tables[smtpbl.SqlEntityX].Rows[0]["Disclaimer"].ToString();
bool EnableSSl = WebHelper.Cast(_ds.Tables[smtpbl.SqlEntityX].Rows[0]["EnableSll"], false);
string EmailAddress = string.Empty;
StudentBAL _stbl = new StudentBAL(0);
_stbl.LoadAll(_ds);
foreach (DataRow dr in _ds.Tables[_stbl.SqlEntityX].Rows)
{
try
{
if (dr["Email"] != DBNull.Value)
{
if (IsValidMailAddress(dr["Email"].ToString()))
{
string Message = "Dear parent,<br/><br/> <br/> The Attendance for current course/semester of your ward," + dr["Name"].ToString() + " is available on the given below link.Please check and contact HOD in case any enquiry.<br/><br/><br/>Copy below link to your browsers address bar. <br/><br/>http://insr.MNMtechnologies.net/login/login.aspx <br/>User Name :" + dr["LoginEmailAddress"].ToString() + "/" + dr["EmailAddress"].ToString() + "<br/>Password : " + dr["Password"].ToString() + "<br/><br/><br/>Regard's<br/><br/>Institute of management.<br/> .";
SMTPHelper SMTP1 = new SMTPHelper(server, smtpPort, From, Password, EnableSSl, true);
SMTP1.IsHTML = true;
SMTP1.SendEmail(From, "Institute of management", dr["Email"].ToString(), "", "", "Attendance status of your ward.", Message, false);
}
}
}
catch (Exception err) { }
}
}
我不知道這是什麼SMTPHelper,但我建議你訪問此頁面:http://www.systemnetmail.com/ – Vince
從過去的經驗來看,我有一個問題,我忘記使用憑據:'系統。 Net.NetworkCredential',如果它可以幫助... – Vince
@Vince代碼工作正常我的個人gmail smtp。但是,如果我使用客戶端SMTP設置我得到這個異常。這意味着代碼工作正常。另外smtp幫手是一個簡單的類發送電子郵件。 – user3563009