Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a work around google disabling "Less secure apps"?

So since the 31 of may google has disabled the option for "Less secure apps", so I have been using the Java mail API, and since the update i can no longer send emails using the Gmail smtp.

This is the error I'm getting:

javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8  https://support.google.com/mail/?p=BadCredentials n13-20020a5d400d000000b0020ff7246934sm4970874wrp.95 - gsmtp

I switched to an outlook mail and it seems to work fine, but i was wondering if there is a way to use a Gmail account

Less secure apps & your Google Account

like image 946
Soske Avatar asked Sep 01 '25 02:09

Soske


1 Answers

You could try authentification via "App password".

On your Google account:

  1. set 2-Step Verification ON

  2. create 16-character "App password"( How to create app password) -> result should be similar to: 16-character "App password"

  3. Instead of Google account password use 16-character password

    MailMessage mail = new MailMessage();
    foreach (string receiver in DolociPrejemnike())
        mail.To.Add(receiver);
    mail.From = new MailAddress("[email protected]", "No replay"); //pošiljatelj (vedno enak)
    mail.Subject = SetSubject();
    mail.Body = SetBody();
    mail.IsBodyHtml = true;
    
    SmtpClient smtp = new SmtpClient();
    smtp.Host = "smtp.gmail.com";
    smtp.Port = 587;
    smtp.UseDefaultCredentials = true;
    smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "xtqapucsmyvqmvxp"); // Enter seders User name and password  
    smtp.EnableSsl = true;
    smtp.Send(mail);
    
like image 183
Petra Marc Avatar answered Sep 04 '25 00:09

Petra Marc