• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java POP3SSLStore类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LogLevel类代码示例发布时间:2022-05-22
下一篇:
Java BaseChromiumApplication类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap