Question

I am using an email program at site: Sending emails without User intervention.

The program runs without problem and does not crash, however the email does not get sent and I do get a list of errors in my log cat and I am not sure why.

The only permission I have is internet, I am not sure if there are any others I need for this program.

Any help would be appreciated, thank you for your time.

Here is log cat:

06-22 15:41:52.216: E/MailApp(675): Could not send email
06-22 15:41:52.216: E/MailApp(675): android.os.NetworkOnMainThreadException
06-22 15:41:52.216: E/MailApp(675):     at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)
06-22 15:41:52.216: E/MailApp(675):     at java.net.InetAddress.lookupHostByName(InetAddress.java:391)
06-22 15:41:52.216: E/MailApp(675):     at java.net.InetAddress.getLocalHost(InetAddress.java:371)
06-22 15:41:52.216: E/MailApp(675):     at javax.mail.internet.InternetAddress.getLocalAddress(InternetAddress.java:517)
06-22 15:41:52.216: E/MailApp(675):     at javax.mail.internet.UniqueValue.getUniqueMessageIDValue(UniqueValue.java:99)
06-22 15:41:52.216: E/MailApp(675):     at javax.mail.internet.MimeMessage.updateMessageID(MimeMessage.java:2054)
06-22 15:41:52.216: E/MailApp(675):     at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:2076)
06-22 15:41:52.216: E/MailApp(675):     at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:2042)
06-22 15:41:52.216: E/MailApp(675):     at javax.mail.Transport.send(Transport.java:117)
06-22 15:41:52.216: E/MailApp(675):     at com.dummies.android.SuperMailTest3.Mail.send(Mail.java:106)
06-22 15:41:52.216: E/MailApp(675):     at com.dummies.android.SuperMailTest3.SuperMailTest3Activity$1.onClick(SuperMailTest3Activity.java:41)
06-22 15:41:52.216: E/MailApp(675):     at android.view.View.performClick(View.java:3511)
06-22 15:41:52.216: E/MailApp(675):     at android.view.View$PerformClick.run(View.java:14105)
06-22 15:41:52.216: E/MailApp(675):     at android.os.Handler.handleCallback(Handler.java:605)
06-22 15:41:52.216: E/MailApp(675):     at android.os.Handler.dispatchMessage(Handler.java:92)
06-22 15:41:52.216: E/MailApp(675):     at android.os.Looper.loop(Looper.java:137)
06-22 15:41:52.216: E/MailApp(675):     at android.app.ActivityThread.main(ActivityThread.java:4424)
06-22 15:41:52.216: E/MailApp(675):     at java.lang.reflect.Method.invokeNative(Native Method)
06-22 15:41:52.216: E/MailApp(675):     at java.lang.reflect.Method.invoke(Method.java:511)
06-22 15:41:52.216: E/MailApp(675):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-22 15:41:52.216: E/MailApp(675):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-22 15:41:52.216: E/MailApp(675):     at dalvik.system.NativeStart.main(Native Method)
Was it helpful?

Solution

You're making network connection in UI thread and additionally you have Strict Mode enabled on your device.

Make connection in background thread or turn off strict mode in developer settings. The first is recommended.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top