Open digiperfect-bharat opened 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...
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
What did you do to solve ?
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).
Ok thanks i got it
This work in background thread
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()
}
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.
I have passed correct credentials but it is failing authentication