yesidlazaro / GmailBackground

a small library to send a email in background withou user interaction
157 stars 70 forks source link

javax.mail.AuthenticationFailedException #15

Open digiperfect-bharat opened 8 years ago

digiperfect-bharat commented 8 years ago

I have passed correct credentials but it is failing authentication

Leepee commented 8 years ago

I found this when I used my main Gmail account, but on creating a fresh one it went straight through. I wonder; do you have 2-factor authentication on your account? Maybe this doesn't handle that properly...

digiperfect-bharat commented 8 years ago

It worked :) Thanks

On Tue, Apr 19, 2016 at 4:18 PM, Leepee notifications@github.com wrote:

I found this when I used my main Gmail account, but on creating a fresh one it went straight through. I wonder; do you have 2-factor authentication on your account? Maybe this doesn't handle that properly...

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/yesidlazaro/GmailBackground/issues/15#issuecomment-211855540

mharunnaik commented 8 years ago

What did you do to solve ?

Leepee commented 8 years ago

You need to use an account without 2 factor authentication enabled, or remove it from the account you want to use. This lib does not support it (honestly it shouldn't).

mharunnaik commented 8 years ago

Ok thanks i got it

bugtsa commented 7 years ago

This work in background thread

burkaslarry commented 6 years ago

Unfortunately, this does not work.

javax.mail.AuthenticationFailedException at javax.mail.Service.connect(Service.java:319) is created

   val runn = Runnable {
                    doLogin(userName , userEmail , message )
                }
                val hand = Handler()
                hand.post(runn ) ;

    private  fun doLogin( name : String , sentEmail : String , message : String ) {
 val password = ""...
val  toMail = ""...
        BackgroundMail.newBuilder(activity)
                .withUsername(sentEmail )
                .withPassword(password)
                .withMailto(toMail)
                .withType(BackgroundMail.TYPE_PLAIN)
                .withSubject("this is the subject")
                .withBody(message)
                .withOnSuccessCallback {
                    Toast.makeText(activity, "send email success" , Toast.LENGTH_SHORT).show()
                }
                .withOnFailCallback {
                    Toast.makeText(activity, "send email failed" , Toast.LENGTH_SHORT).show()
                }
                .send()
    }
Leepee commented 6 years ago

If this doesn't work still, log into the account and tell it to chill about all the security errors. I've had Gmail freak out about multiple logins form different geographic locations quickly. You basically have to make sure that app access is available on the account, and tell it to ignore all the security concerns.