当前位置: 首页>>代码示例>>Java>>正文


Java POP3SSLStore类代码示例

本文整理汇总了Java中com.sun.mail.pop3.POP3SSLStore的典型用法代码示例。如果您正苦于以下问题:Java POP3SSLStore类的具体用法?Java POP3SSLStore怎么用?Java POP3SSLStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


POP3SSLStore类属于com.sun.mail.pop3包,在下文中一共展示了POP3SSLStore类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;

}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:22,代码来源:MailReceiverServiceImpl.java

示例2: connectWithPOP3SSL

import com.sun.mail.pop3.POP3SSLStore; //导入依赖的package包/类
/**
 * API to connect to the email configuration with POP3 server type.
 * 
 * @param emailConfigData {@link EmailConfigurationData}
 * @return
 * @throws MessagingException {@link MessagingException}
 * @throws AuthenticationFailedException {@link AuthenticationFailedException}
 */
public static Store connectWithPOP3SSL(final EmailConfigurationData emailConfigData) throws MessagingException,
		AuthenticationFailedException {
	LOGGER.info("Entering method connectWithPOP3SSL...");
	Properties pop3Props = new Properties();
	pop3Props.setProperty("mail.pop3.socketFactory.class", IUtilCommonConstants.SSL_FACTORY);
	pop3Props.setProperty("mail.pop3.socketFactory.fallback", "false");
	Integer portNumber = emailConfigData.getPortNumber();
	LOGGER.debug("Port Number :: " + portNumber);
	if (portNumber == null) {
		LOGGER.error("Could not find port number. Trying with default value of 995");
		throw new MessagingException("Could not connect to port number " + portNumber
				+ ". Try connecting with defualt port number " + IUtilCommonConstants.DEFAULT_PORT_NUMBER_POP3 + " for pop3 and "
				+ IUtilCommonConstants.DEFAULT_PORT_NUMBER_IMAP + " for IMAP ");
	}
	URLName url = new URLName(emailConfigData.getServerType(), emailConfigData.getServerName(), portNumber, "", emailConfigData
			.getUserName(), emailConfigData.getPassword());

	Session session = Session.getInstance(pop3Props, null);
	Store store = new POP3SSLStore(session, url);
	store.connect();
	LOGGER.info("Exiting method connectWithPOP3SSL...");
	return store;
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:32,代码来源:EmailUtil.java

示例3: 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();
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:31,代码来源:MailClient.java

示例4: MailConnection

import com.sun.mail.pop3.POP3SSLStore; //导入依赖的package包/类
/**
* Construct a new Database MailConnection
* @param protocol the protocol used  : MailConnection.PROTOCOL_POP3 or MailConnection.PROTOCOL_IMAP.
* @param server the target server (ip ou name)
* @param port port number on the server
* @param password
* @param usessl specify if the connection is established via SSL
* @param useproxy specify if we use proxy authentication
* @param proxyusername  proxy authorised user
*/
  public MailConnection(LogChannelInterface log, int protocol, String server, int port, String username, 
  		String password, boolean usessl, boolean useproxy, String proxyusername) throws KettleException {
  	
  	this.log=log;
  	
  	//Get system properties
  	try {
  		this.prop = System.getProperties();
} catch (SecurityException s) {
	this.prop = new Properties();
}

this.port=port;
this.server=server;
this.username=username;
this.password=password;
this.usessl=usessl;
this.protocol=protocol;	
this.nrSavedMessages=0;
this.nrDeletedMessages=0;
this.nrMovedMessages=0;
this.nrSavedAttachedFiles=0;
this.messagenr=-1;
this.useproxy=useproxy;
this.proxyusername=proxyusername;

try{
	
	if(useproxy) {
		// Need here to pass a proxy
		// use SASL authentication 
		this.prop.put("mail.imap.sasl.enable", "true");
		this.prop.put("mail.imap.sasl.authorizationid", proxyusername);
	}
        
	if(protocol==MailConnectionMeta.PROTOCOL_POP3) {
		this.prop.setProperty("mail.pop3s.rsetbeforequit","true"); 
		this.prop.setProperty("mail.pop3.rsetbeforequit","true"); 
	}
	
	String protocolString=(protocol==MailConnectionMeta.PROTOCOL_POP3)?"pop3":"imap";
	if(usessl) {
		// Supports IMAP/POP3 connection with SSL, the connection is established via SSL.
		this.prop.setProperty("mail."+protocolString+".socketFactory.class", "javax.net.ssl.SSLSocketFactory");
		this.prop.setProperty("mail."+protocolString+".socketFactory.fallback", "false");
		this.prop.setProperty("mail."+protocolString+".port",""+port);
		this.prop.setProperty("mail."+protocolString+".socketFactory.port",""+port);
		
		//Create session object
		this.session = Session.getInstance(this.prop, null );
		this.session.setDebug(log.isDebug());
		if(this.port==-1) {
			this.port=((protocol==MailConnectionMeta.PROTOCOL_POP3)?MailConnectionMeta.DEFAULT_SSL_POP3_PORT:MailConnectionMeta.DEFAULT_SSL_IMAP_PORT);
		}
		URLName url = new URLName(protocolString, server, port, "", username, password);	
		this.store = (protocol==MailConnectionMeta.PROTOCOL_POP3)?new POP3SSLStore(this.session, url):new IMAPSSLStore(this.session, url);
		url=null;
	} else {
		this.session = Session.getInstance(this.prop, null);
		this.session.setDebug(log.isDebug());
		this.store = this.session.getStore(protocolString);
	}
	
	if(log.isDetailed()) log.logDetailed(BaseMessages.getString(PKG, "JobGetMailsFromPOP.NewConnectionDefined"));
}catch(Exception e) {
	throw new KettleException(BaseMessages.getString(PKG, "JobGetMailsFromPOP.Error.NewConnection",Const.NVL(this.server,"")),e);
}
  }
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:79,代码来源:MailConnection.java


注:本文中的com.sun.mail.pop3.POP3SSLStore类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。