The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. 21sm5152578pzk.3
System.Net.Mail.MailMessage mymail = new System.Net.Mail.MailMessage("fromAddress", "Toaddress");
mymail.Body = "message body";
mymail.Subject = "message subject";
System.Net.Mail.SmtpClient mysmtpclient = new System.Net.Mail.SmtpClient("smtp.gmail.com.",587);
mysmtpclient.EnableSSL= true;
mysmtpclient.UseDefaultCredentials = false;
mysmtpclient.Credentials = new System.Net.NetworkCredential("gmail id", "gmail password");
mysmtpclient.Send(mm);
I got the exception
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. 21sm5152578pzk.3
Even i had changed the port number to 465, it wont work. But using chilkat smtpclient it is working. How can i overcome this? Please help me!
Loading
Nilanka DharmadasaPosted Dec 21, 2009, 6:34 AM
This is a working code.
Try this. Make sure to give the whole gmail address without giving only the id part.
System.Net.Mail.SmtpClient smtpConnection; smtpConnection = new System.Net.Mail.SmtpClient("smtp.gmail.com");
smtpConnection.Port = 587;//The port
smtpConnection.UseDefaultCredentials = false;
smtpConnection.EnableSsl = true;
smtpConnection.Credentials = new System.Net.NetworkCredential("[email protected]", "gamilpassword");//Username and password to access mail server
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.To.Add("[email protected]");
message.Subject = "mail subject";
message.From = new System.Net.Mail.MailAddress("[email protected]");//Give your from e mail address here
message.Body = "this is mail body";
smtpConnection.Send(message);
If you find this answer helpful, please check 'Do you like this answer' checkbox.
kannanPosted Dec 21, 2009, 6:40 AM
Thaks for saving my life...