I am using this sample code:
http://www.jondev.net/articles/Sending_Emails_without_User_Intervention_%28no_Intents%29_in_Android
I am trying to use my own server email to send email without intent on Android.
I know that sample is configured to works only with Gmail.
I have changed:
_host = "smtp.myserver.com"; // default smtp server
_port = "587"; // default smtp port
_sport = "587"; // default socketfactory port
and this on MainActivity:
Mail m = new Mail("username@myserver.com", "password"); //to my sever email
I just set the right information on Outlook, and it works, I could send and receive from this email.
Server allow this setup:
POP3
SMTP
IMAP
WebMail
Mobile/PDA
Question:
I need to add/change something more? Or this sample can´t work with other then gmail.
I got this error on Logcat:
01-31 21:07:08.989: E/MailApp(17094): Could not send email
01-31 21:07:08.989: E/MailApp(17094): javax.mail.MessagingException: Could not connect to SMTP host: smtp.semhora.com, port: 587;
01-31 21:07:08.989: E/MailApp(17094): nested exception is:
01-31 21:07:08.989: E/MailApp(17094): javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x1e4490: Failure in SSL library, usually a protocol error
01-31 21:07:08.989: E/MailApp(17094): error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol (external/openssl/ssl/s23_clnt.c:683 0xad12957d:0x00000000)
01-31 21:07:08.989: E/MailApp(17094): at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1391)
01-31 21:07:08.989: E/MailApp(17094): at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)
01-31 21:07:08.989: E/MailApp(17094): at javax.mail.Service.connect(Service.java:310)
01-31 21:07:08.989: E/MailApp(17094): at javax.mail.Service.connect(Service.java:169)
01-31 21:07:08.989: E/MailApp(17094): at javax.mail.Service.connect(Service.java:118)
01-31 21:07:08.989: E/MailApp(17094): at javax.mail.Transport.send0(Transport.java:188)
01-31 21:07:08.989: E/MailApp(17094): at javax.mail.Transport.send(Transport.java:118)
01-31 21:07:08.989: E/MailApp(17094): at com.example.sendemailtester.Mail.send(Mail.java:102)
01-31 21:07:08.989: E/MailApp(17094): at com.example.sendemailtester.MainActivity$1.onClick(MainActivity.java:33)
01-31 21:07:08.989: E/MailApp(17094): at android.view.View.performClick(View.java:2485)
01-31 21:07:08.989: E/MailApp(17094): at android.view.View$PerformClick.run(View.java:9080)
01-31 21:07:08.989: E/MailApp(17094): at android.os.Handler.handleCallback(Handler.java:587)
01-31 21:07:08.989: E/MailApp(17094): at android.os.Handler.dispatchMessage(Handler.java:92)
01-31 21:07:08.989: E/MailApp(17094): at android.os.Looper.loop(Looper.java:130)
01-31 21:07:08.989: E/MailApp(17094): at android.app.ActivityThread.main(ActivityThread.java:3687)
01-31 21:07:08.989: E/MailApp(17094): at java.lang.reflect.Method.invokeNative(Native Method)
01-31 21:07:08.989: E/MailApp(17094): at java.lang.reflect.Method.invoke(Method.java:507)
01-31 21:07:08.989: E/MailApp(17094): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
01-31 21:07:08.989: E/MailApp(17094): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
01-31 21:07:08.989: E/MailApp(17094): at dalvik.system.NativeStart.main(Native Method)
01-31 21:07:08.989: E/MailApp(17094): Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x1e4490: Failure in SSL library, usually a protocol error
I’ve never used this wrapper, but the code is assuming SSL support while it appears your port 587 server does not support SSL. Comment out these 2 lines
and set this line from false to true
That might help out.