Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required in .net core

This error

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required.

will appear to the user to send a forgotten password email from the website. Help me, how can I fix it?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Web;
namespace ERP.Senders
{
    public class SendEmail
    {
        public static void Send(string to,string subject,string body)
        {
            MailMessage mail = new MailMessage();
            SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
            mail.From = new MailAddress("noreply.erpsystemmu@gmail.com","سامانه مدیریت منابع انسانی ERP");
            mail.To.Add(to);
            mail.Subject = subject;
            mail.Body = body;
            mail.IsBodyHtml = true;
            //System.Net.Mail.Attachment attachment;
            // attachment = new System.Net.Mail.Attachment("c:/textfile.txt");
            // mail.Attachments.Add(attachment);
            SmtpServer.Port = 587;
            SmtpServer.Credentials = new System.Net.NetworkCredential("noreply.erpsystemmu@gmail.com", "*******");
            SmtpServer.EnableSsl = true;

            SmtpServer.Send(mail);
        }
    }
}

>Solution :

I believe you will need to create an app password, as using the standard email address and password with the Less Secure App Access way of sending emails has been deprecated. I believe you will need to create an app password and use that, coupled with 2-step verification

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading