Java mail fails on Marshmallow and above, but succeeds on Lollipop and below











up vote
0
down vote

favorite












I build an APP to send a short message through Java mail API with a guide from this . It works on my android 5.0.2 phone. But when I deploy it on android 6 or higher, it always failed on authentication.
There is no special change for mail setting compared with the guide mentioned above. I list some of them for information.



    public MailSender(String user, String password, String mailhost) {
this.user = user;
this.password = password;
Log.i("SMTP_mail", mailhost);

Properties props = new Properties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.host", mailhost);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.password", password);
props.put("mail.smtp.starttls.enable","true");
props.put("mail.smtp.socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");
props.setProperty("mail.smtp.quitwait", "false");

session = Session.getDefaultInstance(props, this);
session.setDebug(true);
}


Also, I added permissions check at runtime with a new request from API 23.



        if (ContextCompat.checkSelfPermission(this, Manifest.permission.INTERNET)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
new String{Manifest.permission.INTERNET},
4);
}


And AndroidManifest.xml is as following:



    <uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.MANAGE_OWN_CALLS" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />


With help from the guide for debugging JavaMail, I collect the logs for success and failure.
Success on Android 5:
enter image description here



And failure on Android 6:
enter image description here



The app code is the same for these two logs except the platforms are different.

Also I notice that there are some certificate failure seen on android 6 log, but from stackoverview search, it seems not a big deal. I am not sure whether it impact anything.




E/NativeCrypto: ssl=0x7ba1e98480 cert_verify_callback x509_store_ctx=0x7ba1cfbc98 arg=0x0
ssl=0x7ba1e98480 cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_RSA

I/System.out: gba_cipher_suite:TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA




Could anyone help with this issue? It bothers me for several days. Your help is very appreciated.










share|improve this question
























  • do you have internet permission in your manifest?
    – NIKHIL MAURYA
    yesterday










  • I didnt quite get your question . Do you want send mail from your android app?
    – Kevin Kurien
    yesterday






  • 1




    You're using an ancient version of JavaMail, and the debug output above has exposed your (encoded but not encrypted) password, CHANGE YOUR PASSWORD IMMEDIATELY! Then upgrade to the official JavaMail for Android and if it still fails update your post. Although, I don't see why it would fix the problem since it seems to be the server that is rejecting your login attempt, but you should upgrade anyway.
    – Bill Shannon
    yesterday










  • Thanks a lot for kindly remind, @Bill Shannon. I changed the password. But for this app, it need to support old android phone like android 4.0. The latest Java mail need at least android 4.4. For server rejecting, I am curious why it succeeded with andrid 5 but failed with android 6. Is there other way to help continue to troubleshoot?
    – Q. QQ
    23 hours ago










  • It's the server that's rejecting your login attempt. There's nothing in the debug output that suggests why it might be rejecting it. It's possible that there's a lower level networking problem that's causing it. Perhaps a difference in the SSL/TLS parameters being used? Maybe the password is being sent in two network packets instead of one, and that's triggering a bug in the server? It's hard to say without more information from the server side. Try using a different server just to find out if the problem is specific to smtp.mail.yahoo.com.
    – Bill Shannon
    3 hours ago















up vote
0
down vote

favorite












I build an APP to send a short message through Java mail API with a guide from this . It works on my android 5.0.2 phone. But when I deploy it on android 6 or higher, it always failed on authentication.
There is no special change for mail setting compared with the guide mentioned above. I list some of them for information.



    public MailSender(String user, String password, String mailhost) {
this.user = user;
this.password = password;
Log.i("SMTP_mail", mailhost);

Properties props = new Properties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.host", mailhost);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.password", password);
props.put("mail.smtp.starttls.enable","true");
props.put("mail.smtp.socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");
props.setProperty("mail.smtp.quitwait", "false");

session = Session.getDefaultInstance(props, this);
session.setDebug(true);
}


Also, I added permissions check at runtime with a new request from API 23.



        if (ContextCompat.checkSelfPermission(this, Manifest.permission.INTERNET)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
new String{Manifest.permission.INTERNET},
4);
}


And AndroidManifest.xml is as following:



    <uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.MANAGE_OWN_CALLS" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />


With help from the guide for debugging JavaMail, I collect the logs for success and failure.
Success on Android 5:
enter image description here



And failure on Android 6:
enter image description here



The app code is the same for these two logs except the platforms are different.

Also I notice that there are some certificate failure seen on android 6 log, but from stackoverview search, it seems not a big deal. I am not sure whether it impact anything.




E/NativeCrypto: ssl=0x7ba1e98480 cert_verify_callback x509_store_ctx=0x7ba1cfbc98 arg=0x0
ssl=0x7ba1e98480 cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_RSA

I/System.out: gba_cipher_suite:TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA




Could anyone help with this issue? It bothers me for several days. Your help is very appreciated.










share|improve this question
























  • do you have internet permission in your manifest?
    – NIKHIL MAURYA
    yesterday










  • I didnt quite get your question . Do you want send mail from your android app?
    – Kevin Kurien
    yesterday






  • 1




    You're using an ancient version of JavaMail, and the debug output above has exposed your (encoded but not encrypted) password, CHANGE YOUR PASSWORD IMMEDIATELY! Then upgrade to the official JavaMail for Android and if it still fails update your post. Although, I don't see why it would fix the problem since it seems to be the server that is rejecting your login attempt, but you should upgrade anyway.
    – Bill Shannon
    yesterday










  • Thanks a lot for kindly remind, @Bill Shannon. I changed the password. But for this app, it need to support old android phone like android 4.0. The latest Java mail need at least android 4.4. For server rejecting, I am curious why it succeeded with andrid 5 but failed with android 6. Is there other way to help continue to troubleshoot?
    – Q. QQ
    23 hours ago










  • It's the server that's rejecting your login attempt. There's nothing in the debug output that suggests why it might be rejecting it. It's possible that there's a lower level networking problem that's causing it. Perhaps a difference in the SSL/TLS parameters being used? Maybe the password is being sent in two network packets instead of one, and that's triggering a bug in the server? It's hard to say without more information from the server side. Try using a different server just to find out if the problem is specific to smtp.mail.yahoo.com.
    – Bill Shannon
    3 hours ago













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I build an APP to send a short message through Java mail API with a guide from this . It works on my android 5.0.2 phone. But when I deploy it on android 6 or higher, it always failed on authentication.
There is no special change for mail setting compared with the guide mentioned above. I list some of them for information.



    public MailSender(String user, String password, String mailhost) {
this.user = user;
this.password = password;
Log.i("SMTP_mail", mailhost);

Properties props = new Properties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.host", mailhost);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.password", password);
props.put("mail.smtp.starttls.enable","true");
props.put("mail.smtp.socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");
props.setProperty("mail.smtp.quitwait", "false");

session = Session.getDefaultInstance(props, this);
session.setDebug(true);
}


Also, I added permissions check at runtime with a new request from API 23.



        if (ContextCompat.checkSelfPermission(this, Manifest.permission.INTERNET)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
new String{Manifest.permission.INTERNET},
4);
}


And AndroidManifest.xml is as following:



    <uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.MANAGE_OWN_CALLS" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />


With help from the guide for debugging JavaMail, I collect the logs for success and failure.
Success on Android 5:
enter image description here



And failure on Android 6:
enter image description here



The app code is the same for these two logs except the platforms are different.

Also I notice that there are some certificate failure seen on android 6 log, but from stackoverview search, it seems not a big deal. I am not sure whether it impact anything.




E/NativeCrypto: ssl=0x7ba1e98480 cert_verify_callback x509_store_ctx=0x7ba1cfbc98 arg=0x0
ssl=0x7ba1e98480 cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_RSA

I/System.out: gba_cipher_suite:TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA




Could anyone help with this issue? It bothers me for several days. Your help is very appreciated.










share|improve this question















I build an APP to send a short message through Java mail API with a guide from this . It works on my android 5.0.2 phone. But when I deploy it on android 6 or higher, it always failed on authentication.
There is no special change for mail setting compared with the guide mentioned above. I list some of them for information.



    public MailSender(String user, String password, String mailhost) {
this.user = user;
this.password = password;
Log.i("SMTP_mail", mailhost);

Properties props = new Properties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.host", mailhost);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.password", password);
props.put("mail.smtp.starttls.enable","true");
props.put("mail.smtp.socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");
props.setProperty("mail.smtp.quitwait", "false");

session = Session.getDefaultInstance(props, this);
session.setDebug(true);
}


Also, I added permissions check at runtime with a new request from API 23.



        if (ContextCompat.checkSelfPermission(this, Manifest.permission.INTERNET)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
new String{Manifest.permission.INTERNET},
4);
}


And AndroidManifest.xml is as following:



    <uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.MANAGE_OWN_CALLS" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />


With help from the guide for debugging JavaMail, I collect the logs for success and failure.
Success on Android 5:
enter image description here



And failure on Android 6:
enter image description here



The app code is the same for these two logs except the platforms are different.

Also I notice that there are some certificate failure seen on android 6 log, but from stackoverview search, it seems not a big deal. I am not sure whether it impact anything.




E/NativeCrypto: ssl=0x7ba1e98480 cert_verify_callback x509_store_ctx=0x7ba1cfbc98 arg=0x0
ssl=0x7ba1e98480 cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_RSA

I/System.out: gba_cipher_suite:TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA




Could anyone help with this issue? It bothers me for several days. Your help is very appreciated.







android smtp javamail






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday









Kling Klang

32.1k156287




32.1k156287










asked yesterday









Q. QQ

164




164












  • do you have internet permission in your manifest?
    – NIKHIL MAURYA
    yesterday










  • I didnt quite get your question . Do you want send mail from your android app?
    – Kevin Kurien
    yesterday






  • 1




    You're using an ancient version of JavaMail, and the debug output above has exposed your (encoded but not encrypted) password, CHANGE YOUR PASSWORD IMMEDIATELY! Then upgrade to the official JavaMail for Android and if it still fails update your post. Although, I don't see why it would fix the problem since it seems to be the server that is rejecting your login attempt, but you should upgrade anyway.
    – Bill Shannon
    yesterday










  • Thanks a lot for kindly remind, @Bill Shannon. I changed the password. But for this app, it need to support old android phone like android 4.0. The latest Java mail need at least android 4.4. For server rejecting, I am curious why it succeeded with andrid 5 but failed with android 6. Is there other way to help continue to troubleshoot?
    – Q. QQ
    23 hours ago










  • It's the server that's rejecting your login attempt. There's nothing in the debug output that suggests why it might be rejecting it. It's possible that there's a lower level networking problem that's causing it. Perhaps a difference in the SSL/TLS parameters being used? Maybe the password is being sent in two network packets instead of one, and that's triggering a bug in the server? It's hard to say without more information from the server side. Try using a different server just to find out if the problem is specific to smtp.mail.yahoo.com.
    – Bill Shannon
    3 hours ago


















  • do you have internet permission in your manifest?
    – NIKHIL MAURYA
    yesterday










  • I didnt quite get your question . Do you want send mail from your android app?
    – Kevin Kurien
    yesterday






  • 1




    You're using an ancient version of JavaMail, and the debug output above has exposed your (encoded but not encrypted) password, CHANGE YOUR PASSWORD IMMEDIATELY! Then upgrade to the official JavaMail for Android and if it still fails update your post. Although, I don't see why it would fix the problem since it seems to be the server that is rejecting your login attempt, but you should upgrade anyway.
    – Bill Shannon
    yesterday










  • Thanks a lot for kindly remind, @Bill Shannon. I changed the password. But for this app, it need to support old android phone like android 4.0. The latest Java mail need at least android 4.4. For server rejecting, I am curious why it succeeded with andrid 5 but failed with android 6. Is there other way to help continue to troubleshoot?
    – Q. QQ
    23 hours ago










  • It's the server that's rejecting your login attempt. There's nothing in the debug output that suggests why it might be rejecting it. It's possible that there's a lower level networking problem that's causing it. Perhaps a difference in the SSL/TLS parameters being used? Maybe the password is being sent in two network packets instead of one, and that's triggering a bug in the server? It's hard to say without more information from the server side. Try using a different server just to find out if the problem is specific to smtp.mail.yahoo.com.
    – Bill Shannon
    3 hours ago
















do you have internet permission in your manifest?
– NIKHIL MAURYA
yesterday




do you have internet permission in your manifest?
– NIKHIL MAURYA
yesterday












I didnt quite get your question . Do you want send mail from your android app?
– Kevin Kurien
yesterday




I didnt quite get your question . Do you want send mail from your android app?
– Kevin Kurien
yesterday




1




1




You're using an ancient version of JavaMail, and the debug output above has exposed your (encoded but not encrypted) password, CHANGE YOUR PASSWORD IMMEDIATELY! Then upgrade to the official JavaMail for Android and if it still fails update your post. Although, I don't see why it would fix the problem since it seems to be the server that is rejecting your login attempt, but you should upgrade anyway.
– Bill Shannon
yesterday




You're using an ancient version of JavaMail, and the debug output above has exposed your (encoded but not encrypted) password, CHANGE YOUR PASSWORD IMMEDIATELY! Then upgrade to the official JavaMail for Android and if it still fails update your post. Although, I don't see why it would fix the problem since it seems to be the server that is rejecting your login attempt, but you should upgrade anyway.
– Bill Shannon
yesterday












Thanks a lot for kindly remind, @Bill Shannon. I changed the password. But for this app, it need to support old android phone like android 4.0. The latest Java mail need at least android 4.4. For server rejecting, I am curious why it succeeded with andrid 5 but failed with android 6. Is there other way to help continue to troubleshoot?
– Q. QQ
23 hours ago




Thanks a lot for kindly remind, @Bill Shannon. I changed the password. But for this app, it need to support old android phone like android 4.0. The latest Java mail need at least android 4.4. For server rejecting, I am curious why it succeeded with andrid 5 but failed with android 6. Is there other way to help continue to troubleshoot?
– Q. QQ
23 hours ago












It's the server that's rejecting your login attempt. There's nothing in the debug output that suggests why it might be rejecting it. It's possible that there's a lower level networking problem that's causing it. Perhaps a difference in the SSL/TLS parameters being used? Maybe the password is being sent in two network packets instead of one, and that's triggering a bug in the server? It's hard to say without more information from the server side. Try using a different server just to find out if the problem is specific to smtp.mail.yahoo.com.
– Bill Shannon
3 hours ago




It's the server that's rejecting your login attempt. There's nothing in the debug output that suggests why it might be rejecting it. It's possible that there's a lower level networking problem that's causing it. Perhaps a difference in the SSL/TLS parameters being used? Maybe the password is being sent in two network packets instead of one, and that's triggering a bug in the server? It's hard to say without more information from the server side. Try using a different server just to find out if the problem is specific to smtp.mail.yahoo.com.
– Bill Shannon
3 hours ago












1 Answer
1






active

oldest

votes

















up vote
0
down vote













Add the INTERNET permission to your manifest file.



You have to add this line:



<uses-permission android:name="android.permission.INTERNET" /> 


outside the application tag in your AndroidManifest.xml






share|improve this answer





















  • thanks, Nikhil. I add it also in AndroidManifest.xml. It sitll doesn't work.
    – Q. QQ
    yesterday











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53371649%2fjava-mail-fails-on-marshmallow-and-above-but-succeeds-on-lollipop-and-below%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













Add the INTERNET permission to your manifest file.



You have to add this line:



<uses-permission android:name="android.permission.INTERNET" /> 


outside the application tag in your AndroidManifest.xml






share|improve this answer





















  • thanks, Nikhil. I add it also in AndroidManifest.xml. It sitll doesn't work.
    – Q. QQ
    yesterday















up vote
0
down vote













Add the INTERNET permission to your manifest file.



You have to add this line:



<uses-permission android:name="android.permission.INTERNET" /> 


outside the application tag in your AndroidManifest.xml






share|improve this answer





















  • thanks, Nikhil. I add it also in AndroidManifest.xml. It sitll doesn't work.
    – Q. QQ
    yesterday













up vote
0
down vote










up vote
0
down vote









Add the INTERNET permission to your manifest file.



You have to add this line:



<uses-permission android:name="android.permission.INTERNET" /> 


outside the application tag in your AndroidManifest.xml






share|improve this answer












Add the INTERNET permission to your manifest file.



You have to add this line:



<uses-permission android:name="android.permission.INTERNET" /> 


outside the application tag in your AndroidManifest.xml







share|improve this answer












share|improve this answer



share|improve this answer










answered yesterday









NIKHIL MAURYA

1419




1419












  • thanks, Nikhil. I add it also in AndroidManifest.xml. It sitll doesn't work.
    – Q. QQ
    yesterday


















  • thanks, Nikhil. I add it also in AndroidManifest.xml. It sitll doesn't work.
    – Q. QQ
    yesterday
















thanks, Nikhil. I add it also in AndroidManifest.xml. It sitll doesn't work.
– Q. QQ
yesterday




thanks, Nikhil. I add it also in AndroidManifest.xml. It sitll doesn't work.
– Q. QQ
yesterday


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53371649%2fjava-mail-fails-on-marshmallow-and-above-but-succeeds-on-lollipop-and-below%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Cypress Hill

what are some tips for doing well in the interview? [on hold]

How does a super-power salesman not get shut down for legal reasons?