Authentication failed error while sending mail (host : gmail)

Hi ,
Please advice on this .

Getting error while sending mail Authentication failed.

at #=zEvGFwbteQad6Bgd3tBVn6uNT3sDYoeIHb0OSNHA=.#=zitk7o2E=(String #=z4vfBkTU=, Int32 #=zbO3CvpE=)
at #=zEvGFwbteQad6Bgd3tBVn6uNT3sDYoeIHb0OSNHA=.#=zUGAYQTU=(String #=z4vfBkTU=, Int32 #=zbO3CvpE=)

Code :

{
HttpProxy proxy = new HttpProxy(“192.16.0.1”, 8888);

            using (SmtpClient client = new SmtpClient("smtp.gmail.com", 587, "xyz@gmail.com", "nagsiohschmydupg"))
            {
                client.Proxy = proxy;
                client.Send(new MailMessage(
                    "xyz@gmail.com",
                    "xyz@gmail.com",
                    "NETWORKNET-34226 - " + Guid.NewGuid().ToString(),
                    "NETWORKNET-34226 Implement socks proxy protocol for versions 4, 4a, 5 (only Username/Password authentication)"));
            }

}

@vikasaspos

Could you please share the SmtpClient activity log? Please read the following article about implementing it.
SmtpClient Activity Logging

@tahir.manzoor below is the activity logs . Please have a look

— Aspose.Email for .NET 4.0 [22.5.0.0] SMTP Client diagnostic log

— Started: 6/21/2022 11:13:32 PM

Smtp client[1|6/21/2022 11:13:34 PM]:
Smtp client[1|6/21/2022 11:13:34 PM]:
6/21/2022 11:13:34 PM

Smtp client[1|6/21/2022 11:13:34 PM]: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Connect to: smtp.gmail.com:587 SecurityOptions.SSLExplicit <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Smtp client[1|6/21/2022 11:13:34 PM]:
6/21/2022 11:13:34 PM

Smtp client[1|6/21/2022 11:13:34 PM]: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Environment version: 4.0.30319.42000 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Smtp client[1|6/21/2022 11:13:34 PM]:
6/21/2022 11:13:34 PM

Smtp client[1|6/21/2022 11:13:34 PM]: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> OS version: Microsoft Windows NT 6.2.9200.0 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Smtp client[1|6/21/2022 11:13:34 PM]:
6/21/2022 11:13:34 PM

Smtp client[1|6/21/2022 11:13:34 PM]: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Assembly title: Aspose.Email for .NET 4.0 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Smtp client[1|6/21/2022 11:13:34 PM]:
6/21/2022 11:13:34 PM

Smtp client[1|6/21/2022 11:13:34 PM]: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Assembly version: 22.5.0.0 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Smtp client[1|6/21/2022 11:13:34 PM]:
6/21/2022 11:13:34 PM

Smtp client[1|6/21/2022 11:13:34 PM]:
Smtp client[1|6/21/2022 11:13:34 PM]:
6/21/2022 11:13:34 PM

Smtp server[1|6/21/2022 11:13:36 PM]: 220 smtp.gmail.com ESMTP q5-20020a170902a3c500b0016a38fa3f95sm1829290plb.118 - gsmtp
Smtp server[1|6/21/2022 11:13:36 PM]:
6/21/2022 11:13:36 PM

Smtp client[1|6/21/2022 11:13:36 PM]: EHLO WIN-109OGN85ED4
Smtp client[1|6/21/2022 11:13:36 PM]:
6/21/2022 11:13:36 PM

Smtp server[1|6/21/2022 11:13:37 PM]: 250-smtp.gmail.com at your service, [14.141.226.242]
Smtp server[1|6/21/2022 11:13:37 PM]: 250-SIZE 35882577
Smtp server[1|6/21/2022 11:13:37 PM]: 250-8BITMIME
Smtp server[1|6/21/2022 11:13:37 PM]: 250-STARTTLS
Smtp server[1|6/21/2022 11:13:37 PM]: 250-ENHANCEDSTATUSCODES
Smtp server[1|6/21/2022 11:13:37 PM]: 250-PIPELINING
Smtp server[1|6/21/2022 11:13:37 PM]: 250-CHUNKING
Smtp server[1|6/21/2022 11:13:37 PM]: 250 SMTPUTF8
Smtp server[1|6/21/2022 11:13:37 PM]:
6/21/2022 11:13:37 PM

Smtp client[1|6/21/2022 11:13:37 PM]: STARTTLS
Smtp client[1|6/21/2022 11:13:37 PM]:
6/21/2022 11:13:37 PM

Smtp server[1|6/21/2022 11:13:37 PM]: 220 2.0.0 Ready to start TLS
Smtp server[1|6/21/2022 11:13:37 PM]:
6/21/2022 11:13:37 PM

Smtp client[1|6/21/2022 11:13:37 PM]: EHLO WIN-109OGN85ED4
Smtp client[1|6/21/2022 11:13:37 PM]:
6/21/2022 11:13:37 PM

Smtp client[1|6/21/2022 11:13:37 PM]:
Smtp client[1|6/21/2022 11:13:37 PM]:
6/21/2022 11:13:37 PM

Smtp client[1|6/21/2022 11:13:37 PM]: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Connect to: smtp.gmail.com:587 SecurityOptions.None <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Smtp client[1|6/21/2022 11:13:37 PM]:
6/21/2022 11:13:37 PM

Smtp client[1|6/21/2022 11:13:37 PM]: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Environment version: 4.0.30319.42000 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Smtp client[1|6/21/2022 11:13:37 PM]:
6/21/2022 11:13:37 PM

Smtp client[1|6/21/2022 11:13:37 PM]: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> OS version: Microsoft Windows NT 6.2.9200.0 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Smtp client[1|6/21/2022 11:13:37 PM]:
6/21/2022 11:13:37 PM

Smtp client[1|6/21/2022 11:13:37 PM]: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Assembly title: Aspose.Email for .NET 4.0 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Smtp client[1|6/21/2022 11:13:37 PM]:
6/21/2022 11:13:37 PM

Smtp client[1|6/21/2022 11:13:37 PM]: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Assembly version: 22.5.0.0 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Smtp client[1|6/21/2022 11:13:37 PM]:
6/21/2022 11:13:37 PM

Smtp client[1|6/21/2022 11:13:37 PM]:
Smtp client[1|6/21/2022 11:13:37 PM]:
6/21/2022 11:13:37 PM

Smtp server[1|6/21/2022 11:13:37 PM]: 220 smtp.gmail.com ESMTP y6-20020a056a00180600b0051c147eee7bsm11779389pfa.110 - gsmtp
Smtp server[1|6/21/2022 11:13:37 PM]:
6/21/2022 11:13:37 PM

Smtp client[1|6/21/2022 11:13:37 PM]: EHLO WIN-109OGN85ED4
Smtp client[1|6/21/2022 11:13:37 PM]:
6/21/2022 11:13:37 PM

Smtp server[1|6/21/2022 11:13:37 PM]: 250-smtp.gmail.com at your service, [14.141.226.242]
Smtp server[1|6/21/2022 11:13:37 PM]: 250-SIZE 35882577
Smtp server[1|6/21/2022 11:13:37 PM]: 250-8BITMIME
Smtp server[1|6/21/2022 11:13:37 PM]: 250-STARTTLS
Smtp server[1|6/21/2022 11:13:37 PM]: 250-ENHANCEDSTATUSCODES
Smtp server[1|6/21/2022 11:13:37 PM]: 250-PIPELINING
Smtp server[1|6/21/2022 11:13:37 PM]: 250-CHUNKING
Smtp server[1|6/21/2022 11:13:37 PM]: 250 SMTPUTF8
Smtp server[1|6/21/2022 11:13:37 PM]:
6/21/2022 11:13:37 PM

@vikasaspos

We have logged this problem in our issue tracking system as EMAILNET-40627. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@tahir.manzoor
I have tried below code as well . But got error “Unable to write data to the transport connection: An established connection was aborted by the software in your host machine.”

SmtpClient client = new SmtpClient(“smtp.gmail.com”, 587, “xtz@gmail.com”, “gdjsjhgdgsds”);
client.SecurityOptions = SecurityOptions.SSLImplicit;
string proxyAddress = “172.16.0.1”; // proxy address
int proxyPort = 3128; // proxy port
SocksProxy proxy = new SocksProxy(proxyAddress, proxyPort, SocksVersion.SocksV5);
client.Proxy = proxy;

            client.Send(new MailMessage("xyz@gmail.com", "xyz@gmail.com", "Sending Email via proxy", "Implement socks proxy protocol for versions 4, 4a, 5 (only Username/Password authentication)"));

@vikasaspos

Your issue has been logged for investigation. We will investigate the issue and provide you more information on it. Thanks for your patience.

@vikasaspos

In your case, we suggest you please do not use proxy. Secondly, make sure that in the user Google account, in the Security section, the parameter “Less secure app access” is set as shown in attachment.
security.jpg (213.5 KB)

If this parameter is Off then “Authentication failed” error will be raised. We have closed the ticket EMAILNET-40627.