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.'

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.'

I'm trying to send a email through a C# application.
Here's the code:
using (SmtpClient smtp = new SmtpClient("smtp.zoho.com", 587))
                {
                    smtp.EnableSsl = true;
                    smtp.UseDefaultCredentials = false;
                    smtp.Credentials = new NetworkCredential("from", "password");
                    using (MailMessage msg = new MailMessage("from", "to"))
                    {
                        msg.Subject = message;
                        msg.Body = $"[{ logEvent.Timestamp}] - { logEvent.Level} - { message}\r\n{ exceptionMessage }";

                        smtp.Send(msg);
                    }
                }

The password is the one generated in the App Passwords menu, for that user, but I keep getting that error.
And after every time I try to send an email through code, I get the following message, in the App Passwords tab:

Looks like you are about to perform a sensitive operation. Please confirm your identity to proceed further.