Email from gmail server to ASP. NET
Demir last edited by
Guys, good time for 24 hours, I'm trying to reinstate the password through a soap letter. Here's the cat.
// MailMessage class is present is System.Net.Mail namespace MailMessage mailMessage = new MailMessage("firstname.lastname@example.org", ToEmail);
// StringBuilder class is present in System.Text namespace
StringBuilder sbEmailBody = new StringBuilder();
sbEmailBody.Append("Уважаемый " + UserName + ",<br/><br/>");
sbEmailBody.Append("Пожалуйста, нажмите на ссылку, чтобы ввести новый пароль");
sbEmailBody.Append("<br/>"); sbEmailBody.Append("http://localhost/WebApplication1/Registration/ChangePassword.aspx?uid=" + UniqueId);
sbEmailBody.Append("<b>Администрация херсонского автосервиса</b>");
mailMessage.IsBodyHtml = true;
mailMessage.Body = sbEmailBody.ToString();
mailMessage.Subject = "Смена пароля";
SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
smtpClient.Credentials = new System.Net.NetworkCredential("email@example.com", "пароль");
smtpClient.EnableSsl = true;
SMTP had a secure connection, or the client ' s authenticity had not been established.
Server response: 5.5.1 Authentication Required. Learn more at*
Handing on the last line. On firstname.lastname@example.org, it was reported that an entrance attempt had been blocked. What's to fix?
You probably have two-factor copying. This option is now default for all new users.
If you don't particularly care about the safety of your account... https://security.google.com/settings/security/apppasswords and use it in the code.
In case security is important or the mailing will be used against the names of many users (mainly your clients) - look at the side. https://developers.google.com/gmail/xoauth2_protocol ♪
OAuth allows for a severe limitation of the rights of the annex. In particular, it is possible to give an annex the right only to send postal messages and nothing more than to access other Google services or to look at postal messages. It is also possible to use RESTful API, which allows for the use of SMTP-server at all.
Turns out, since mid-2014, Google announced http://googleappsupdates.blogspot.ru/2015/09/block-access-to-less-secure_15.html and all records prohibited the entry of such applications by default. In turn, only OAuth-authorization applications are considered reliable.
For those users with two-factor copying, their use remains possible on the application password.
And users whose two-factor copying was not included added https://www.google.com/settings/security/lesssecureapps default.