【发布时间】:2017-05-29 17:10:42
【问题描述】:
在 Oracl sslnotes 中说,STARTTLS 命令应该通过使用 mail.imap.starttls.enable 或 mail.smtp.starttls.enable 来启用,设置为“true”。 "设置后,如果服务器支持 STARTTLS 命令,则 在建立连接之后和发送任何登录信息之前使用 信息”。因此,我按照建议进行了设置:
props.setProperty("mail.imap.starttls.enable", "true");
props.setProperty("mail.store.protocol", "imap");
props.setProperty("mail.imap.auth", "true");
props.setProperty("mail.imap.host", "imap.mail.ru");
Session session = Session.getInstance(props, new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(login + "@" + server, passwd);
}
});
session.setDebug( true);
Store store = session.getStore();
store.connect();
但这是对话:
* OK Welcome
A0 CAPABILITY
* CAPABILITY IMAP4rev1 ID XLIST UIDPLUS UNSELECT MOVE STARTTLS LIST-STATUS LOGINDISABLED
A0 OK CAPABILITY completed
A1 LOGIN tester@mail.ru tester <==== this string is edited
A1 NO [PRIVACYREQUIRED] Command disabled. Please use STARTTLS first.
据我了解,连接函数没有发送 STARTTLS 命令(尽管该命令应该在“建立连接之后发送任何登录信息之前”发送,正如 Oracle 手册中所承诺的那样)。那么我应该怎么做才能让代码发送这个 STARTTLS 呢?
【问题讨论】:
-
您可以尝试将
mail.imap.starttls.required也指定为 true 吗?