私は自分のメールをアプリでチェックしたいと思っています。これまでの私のコード:はPOP3サーバーに接続できません
私のプロバイダはSSLを使用しています。 hereを参照してください。これまで
私のコードは:
try {
//1) get the session object
Properties properties = new Properties();
properties.put("mail.pop3s.host", "pop.1und1.de");
properties.put("mail.pop3s.port", "995");
Session emailSession = Session.getDefaultInstance(properties);
//2) create the POP3 store object and connect with the pop server
POP3Store emailStore = (POP3Store) emailSession.getStore("pop3s");
emailStore.connect(<myMailAdress>, <password>);
//3) create the folder object and open it
Folder emailFolder = emailStore.getFolder("INBOX");
emailFolder.open(Folder.READ_ONLY);
//4) retrieve the messages from the folder in an array and print it
Message[] messages = emailFolder.getMessages();
for(Message message:messages) {
String from = message.getFrom()[0].toString().toLowerCase();
Log.e("XXXXXX",from);
}
emailFolder.close(false);
emailStore.close();
} catch (NoSuchProviderException e) {
e.printStackTrace();
}
catch (MessagingException e) {
e.printStackTrace();
}
コードがemailStore.connect()
まで実行されます。そこに私は例外を得る javax.mail.MessagingException: Connect failed; nested exception is: javax.net.ssl.SSLHandshakeException: Connection closed by peer
。
JavaMailはデフォルトのポートを認識します。指定する必要はありません。これらの[接続のデバッグのヒント](http://www.oracle.com/technetwork/java/javamail/faq/index.html#condebug)に従ってください。接続時にサーバーでSSLを使用する必要がないことを確認してください。そうであれば、 'mail.pop3.ssl.enable'を" true "に設定してください。 –
私のコードを編集して別のエラーメッセージが出ました。私の編集されたポストを参照してください。また、設定のあるプロバイダへのリンクも含まれています – Ginso
[JavaMailセッションのデバッグ](http://www.oracle.com/technetwork/java/javamail/faq/index.html#debug)をオンにし、それはおそらくあなたに十分な情報を与えません。 JavaMail [SSLNOTES.txt](http://javamail.java.net/docs/SSLNOTES.txt)ファイルのリンクで説明されているように、java.net SSLデバッグを有効にする必要があります。 –