Guys I have a class where I am sending mail to all the students in database.When I send mails on my local host mails get send easily but when I upload my code to the server. I am getting this exception :
System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response) at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, MailAddress from, Boolean allowUnicode) at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, Boolean allowUnicode, SmtpFailedRecipientException& exception) at System.Net.Mail.SmtpClient.Send(MailMessage message) at HotelWeb.SMTPHelper.SendEmail(String From, String FromDisplayName, String To, String Cc, String Bcc, String Subject, String Body, Boolean SendMailInBackGround) in e:\hostingspaces\ubi9009\ihmsgr.taqwatechnologies.net\wwwroot\App_Code\SMTPHelper.cs:line 140 at HotelWeb.MAILnSMS.sendBulkMail() in e:\
hostingspaces\ubi9009\ihmsgr.taqwatechnologies.net\wwwroot\App_Code\MAILnSMS.cs:line 95
My code works fine on local machine but doestnt work on server is like this :
public static void sendBulkMail() {
_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://ihmsgr.taqwatechnologies.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 hotel management.<br/>Srinagar.";
SMTPHelper SMTP1 = new SMTPHelper(server, smtpPort, From, Password, EnableSSl, true);
SMTP1.IsHTML = true;
SMTP1.SendEmail(From, "Institute of hotel management", dr["Email"].ToString(), "", "", "Attendance status of your ward.", Message, false);
}
}
}
catch (Exception err) {
}
}
}
I am using hosting space on Server http://www.arvixe.com/ PLEASE HELP