3

I am following this tutorial for sending Emails from My App.

When i try to run this in my emulator its getting error as

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

I have given all the permissions too.

I am so wonder that the same project running without any errors in my friend system. Is there any external setup for sending mails in my system.

Any suggestions??

2 Answers 2

1

try ping smtp.gmail.com and make sure you got a response (able to access). Often times, your connection may block by your firewall or proxy behind.

Sign up to request clarification or add additional context in comments.

Comments

0

Check if your device is connected to the internet( wifi ). If not, connect to wifi or open your connection then try to simulate the send functionality of your application again.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.