本文整理汇总了Java中com.sun.mail.pop3.POP3SSLStore.connect方法的典型用法代码示例。如果您正苦于以下问题:Java POP3SSLStore.connect方法的具体用法?Java POP3SSLStore.connect怎么用?Java POP3SSLStore.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.mail.pop3.POP3SSLStore
的用法示例。
在下文中一共展示了POP3SSLStore.connect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connectWithPOP3SSL
import com.sun.mail.pop3.POP3SSLStore; //导入方法依赖的package包/类
public Store connectWithPOP3SSL(BatchClassEmailConfiguration configuration) throws MessagingException {
Properties pop3Props = new Properties();
pop3Props.setProperty("mail.pop3.socketFactory.class", MailConstants.SSL_FACTORY);
pop3Props.setProperty("mail.pop3.socketFactory.fallback", "false");
Integer portNumber = configuration.getPortNumber();
if (portNumber == null) {
LOGGER.error("Could not find port number. Trying with default value of 995");
portNumber = MailConstants.DEFAULT_PORT_NUMBER_POP3;
}
URLName url = new URLName(configuration.getServerType(), configuration.getServerName(), portNumber, "", configuration
.getUserName(), configuration.getPassword());
session = Session.getInstance(pop3Props, null);
store = new POP3SSLStore(session, url);
store.connect();
return store;
}
示例2: connect
import com.sun.mail.pop3.POP3SSLStore; //导入方法依赖的package包/类
/**
* connects to pop server
* @throws MessagingException
*/
public void connect() throws MessagingException {
Properties properties = new Properties();
String type=getTypeAsString();
properties.put("mail."+type+".host", server);
properties.put("mail."+type+".port", new Double(port));
properties.put("mail."+type+".connectiontimeout", String.valueOf(timeout));
properties.put("mail."+type+".timeout", String.valueOf(timeout));
//properties.put("mail.mime.charset", "UTF-8");
if(TYPE_IMAP==getType()) properties.put("mail.imap.partialfetch", "false" );
else {
if(secure) properties.put("mail.pop3.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); // will failover
}
_fldtry = username != null ? Session.getInstance(properties, new _Authenticator(username, password)) : Session.getInstance(properties);
if(TYPE_POP3==getType() && secure) {
URLName url = new URLName("pop3", server, port, "",username, password);
_fldelse = new POP3SSLStore(_fldtry, url);
} else {
_fldelse = _fldtry.getStore(type);
}
if(!StringUtil.isEmpty(username))_fldelse.connect(server,username,password);
else _fldelse.connect();
}