3

我正在按照教程从我的应用程序发送电子邮件。

当我尝试在我的模拟器中运行它时,它会出现错误

08-10 08:40:47.839: W/System.err(526): javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465;
08-10 08:40:47.849: W/System.err(526):   nested exception is:
08-10 08:40:47.849: W/System.err(526):  java.net.SocketException: Host is unresolved: smtp.gmail.com
08-10 08:40:47.859: W/System.err(526):  at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1391)
08-10 08:40:47.859: W/System.err(526):  at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)
08-1 08:40:47.859: W/System.err(526):   at javax.mail.Service.connect(Service.java:310)
08-10 08:40:47.859: W/System.err(526):  at javax.mail.Service.connect(Service.java:169)
08-10 08:40:47.859: W/System.err(526):  at javax.mail.Service.connect(Service.java:118)
08-10 08:40:47.859: W/System.err(526):  at javax.mail.Transport.send0(Transport.java:188)
08-10 08:40:47.859: W/System.err(526):  at javax.mail.Transport.send(Transport.java:118)
08-10 08:40:47.859: W/System.err(526):  at com.mythrii.punchclockpro.Mails.send(Mails.java:107)
08-10 08:40:47.869: W/System.err(526):  at com.mythrii.punchclockpro.login$DownloadImageTask.doInBackground(login.java:277)
08-10 08:40:47.869: W/System.err(526):  at com.mythrii.punchclockpro.login$DownloadImageTask.doInBackground(login.java:1)
08-10 08:40:47.869: W/System.err(526):  at android.os.AsyncTask$2.call(AsyncTask.java:185)
08-10 08:40:47.869: W/System.err(526):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
08-10 08:40:47.869: W/System.err(526):  at java.util.concurrent.FutureTask.run(FutureTask.java:138)
08-10 08:40:47.869: W/System.err(526):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
08-10 08:40:47.869: W/System.err(526):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
08-10 08:40:47.869: W/System.err(526):  at java.lang.Thread.run(Thread.java:1019)
08-10 08:40:47.869: W/System.err(526): Caused by: java.net.SocketException: Host is unresolved: smtp.gmail.com
08-10 08:40:47.869: W/System.err(526):  at java.net.Socket.connect(Socket.java:966)
08-10 08:40:47.880: W/System.err(526):  at java.net.Socket.connect(Socket.java:926)
08-10 08:40:47.880: W/System.err(526):  at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:233)
08-10 08:40:47.880: W/System.err(526):  at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:163)
08-10 08:40:47.880: W/System.err(526):  at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1359)
08-10 08:40:47.880: W/System.err(526):  ... 15 more

我也给了所有的权限。

我很想知道同一个项目在我的朋友系统中运行时没有任何错误。我的系统中是否有任何外部设置sending mails

有什么建议么??

4

2 回答 2

1

尝试 pingsmtp.gmail.com并确保您得到响应(能够访问)。通常,您的连接可能会被您的防火墙或代理阻止。

于 2012-08-10T04:08:57.983 回答
0

检查您的设备是否已连接到互联网(wifi)。如果没有,请连接到 wifi 或打开连接,然后尝试再次模拟应用程序的发送功能。

于 2014-01-06T08:14:04.613 回答