0

I just make a mail class refer to this

and javax.mail.AuthenticationFailedException occurred with return null.

11-26 22:51:25.053 19008-20169/com.example.android.mailGenerater E/AndroidRuntime: FATAL EXCEPTION: Thread-7 Process: com.example.android.mailGenerater, PID: 19008 javax.mail.AuthenticationFailedException at javax.mail.Service.connect(Service.java:319) at javax.mail.Service.connect(Service.java:169) at javax.mail.Service.connect(Service.java:118) at javax.mail.Transport.send0(Transport.java:188) at javax.mail.Transport.send(Transport.java:118) at com.example.android.mailGenerater.SendGmailManager(SendGmailManager.kt:145) at com.example.android.mailGenerater.MyActivity$onCreate$1$1.run(MyActivity.kt:60)

I used exception code with it

 catch (e: AuthenticationFailedException) {
        Log.d(TAG, "auth failed : ${e.localizedMessage}") // print : "auth failed : null"
        e.printStackTrace() // not working.

It show nothing.

that exception return null, so print stack trace not working.


I want to know when AuthenticationFailedException occurred with null

Sudarshan
  • 367
  • 2
  • 8
  • 20
mgcation
  • 517
  • 6
  • 17

1 Answers1

0

Sorry

this problem rely on all my mistake.

I miss bellow code at child class of javax.mail.Authenticator

protected PasswordAuthentication getPasswordAuthentication() {   
    return new PasswordAuthentication(user, password);   
} 

I think Null occurred when if there is no override method : getPasswordAuthentication()

when i add override method, it work very well.

mgcation
  • 517
  • 6
  • 17
  • Note that you probably [don't even need to use an Authenticator](https://javaee.github.io/javamail/FAQ#commonmistakes) at all. – Bill Shannon Nov 28 '17 at 20:24