Android JavaMail无法发送消息

时间:2013-06-04 12:00:20

标签: android javamail

我按照Link指令发送邮件。我添加了Internet使用权限以及在AsyncTask中发送电子邮件呼叫的方法。但我仍然无法发送电子邮件。我始终在行Transport.send(message);中收到广告错误。

这是我的printStack:06-04 14:49:32.203: W/System.err(32750): java.lang.SecurityException: Permission denied (missing INTERNET permission?) 06-04 14:49:32.203: W/System.err(32750): at java.net.InetAddress.lookupHostByName(InetAddress.java:428) 06-04 14:49:32.203: W/System.err(32750): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:239) 06-04 14:49:32.203: W/System.err(32750): at java.net.InetAddress.getByName(InetAddress.java:292) 06-04 14:49:32.203: W/System.err(32750): at javax.mail.URLName.getHostAddress(URLName.java:487) 06-04 14:49:32.203: W/System.err(32750): at javax.mail.URLName.hashCode(URLName.java:463) 06-04 14:49:32.203: W/System.err(32750): at java.util.Hashtable.get(Hashtable.java:263) 06-04 14:49:32.203: W/System.err(32750): at javax.mail.Session.getPasswordAuthentication(Session.java:823) 06-04 14:49:32.203: W/System.err(32750): at javax.mail.Service.connect(Service.java:271) 06-04 14:49:32.213: W/System.err(32750): at javax.mail.Service.connect(Service.java:169) 06-04 14:49:32.213: W/System.err(32750): at javax.mail.Service.connect(Service.java:118) 06-04 14:49:32.213: W/System.err(32750): at javax.mail.Transport.send0(Transport.java:188) 06-04 14:49:32.213: W/System.err(32750): at javax.mail.Transport.send(Transport.java:118) 06-04 14:49:32.213: W/System.err(32750): at com.vakoms.infouser.utils.GmailSender.sendMail(GmailSender.java:66) 06-04 14:49:32.213: W/System.err(32750): at com.vakoms.infouser.utils.SendMessageTask.send(SendMessageTask.java:31) 06-04 14:49:32.213: W/System.err(32750): at com.vakoms.infouser.utils.SendMessageTask.doInBackground(SendMessageTask.java:16) 06-04 14:49:32.213: W/System.err(32750): at com.vakoms.infouser.utils.SendMessageTask.doInBackground(SendMessageTask.java:1) 06-04 14:49:32.213: W/System.err(32750): at android.os.AsyncTask$2.call(AsyncTask.java:287) 06-04 14:49:32.213: W/System.err(32750): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 06-04 14:49:32.223: W/System.err(32750): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 06-04 14:49:32.223: W/System.err(32750): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) 06-04 14:49:32.223: W/System.err(32750): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 06-04 14:49:32.223: W/System.err(32750): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 06-04 14:49:32.223: W/System.err(32750): at java.lang.Thread.run(Thread.java:864) 06-04 14:49:32.223: W/System.err(32750): Caused by: libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname) 06-04 14:49:32.223: W/System.err(32750): at libcore.io.Posix.getaddrinfo(Native Method) 06-04 14:49:32.223: W/System.err(32750): at libcore.io.ForwardingOs.getaddrinfo(ForwardingOs.java:55) 06-04 14:49:32.223: W/System.err(32750): at java.net.InetAddress.lookupHostByName(InetAddress.java:415) 06-04 14:49:32.233: W/System.err(32750): ... 22 more 06-04 14:49:32.233: W/System.err(32750): Caused by: libcore.io.ErrnoException: getaddrinfo failed: EACCES (Permission denied) 06-04 14:49:32.233: W/System.err(32750): ... 25 more

1 个答案:

答案 0 :(得分:1)

您的许可名称中有拼写错误。它应该是:

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

而不是...android.permissoin...