Sorry, I saw a lot of similar post regarding this matter but never found any solution to my problem, so I decided to post it.
I am using ASP.NET c# to send email programmatically using gmail with the following code.
string EmailAddress = senderemail;
MailMessage mailMessage = new MailMessage(EmailAddress, EmailAddress);
mailMessage.Subject = "This is a test email";
mailMessage.Body = "This is a test email. Please reply if you receive it.";
SmtpClient smtpClient = new SmtpClient();
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.EnableSsl = true;
smtpClient.Host = "smtp.gmail.com";
smtpClient.Port = 587;
smtpClient.Credentials = new System.Net.NetworkCredential()
{
UserName = EmailAddress,
Password = senderpassword
};
smtpClient.UseDefaultCredentials = false;
smtpClient.Send(mailMessage);
I received this error like everybody else
Error:
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.
Already did below 2 action from GMAIL.
-less secure app : turn on
-2 step verification : off
I don't care whether is this gmail account safe or what. I don't need any security for this account. What else should i do?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…