Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i am creating the website with code of sending mail, in this website the mail will send from my localhost and after publish code on my system iis server, but if i will place this site on cpanel( hosting on web) then the mail not send on mail id mention in code...and executing following error

error:::::

CSS
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

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: 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

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:



and the code follows:



name = txtname.Text;
mobileno = txtmob.Text;

email = txtemailid.Text;
// msg = txtmessage.Text;
tot = lbl_total.Text;


to = "abc@gmail.com";

subject = "Email From buyer";
// var body = "Name:" + name + "\n Mobile No: " + mobileno + "\n Email ID:" + email + "\n Product Code: " + productcode + "\n Total Price:" + tot + "";
var body = "
contents goes here..
";
string from = email;

System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(from, to, subject, body);
mailMessage.IsBodyHtml = true;
//Proper Authentication Details need to be passed when sending email from gmail
System.Net.NetworkCredential mailAuthentication = new
System.Net.NetworkCredential("name of mail", "password");
//Smtp Mail server of Gmail is "smpt.gmail.com" and it uses port no. 587
//For different server like yahoo this details changes and you can
//get it from respective server.
System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587);
//Enable SSL
mailClient.EnableSsl = true;
mailClient.UseDefaultCredentials = false;
mailClient.Credentials = mailAuthentication;
mailClient.Send(mailMessage);
//txtName.Text = "";
//txtMobile.Text = "";
//txtEmail.Text = "";
//txtMsg.Text = "";
AJAXMessageBox(this, "Email is sent Successfully...");

string senderusername = "myname";
string senderid = "A2";
string pass = "mySMS4";
string mobile="0000000000";

string msg = "Name: " + name + "\n Mobile No: " + mobileno + "\n Email ID: " + email + "\n Total Price: " + tot + "\n Product Code: " + productcode + "";


string sURL;
sURL = "http://124.345 username=" + senderusername + "&password=" + pass + "&sendername=" + senderid + "&mobileno=" + mobile + "&message=" + msg;

WebRequest request = HttpWebRequest.Create(sURL);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream s = (Stream)response.GetResponseStream();
StreamReader readStream = new StreamReader(s);
string dataString = readStream.ReadToEnd();
// lblResultAudit.Text = dataString;
response.Close();
s.Close();
readStream.Close();
txtemailid.Text = "";
txtmob.Text = "";
txtname.Text = "";


}
}
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900