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


Java JavaMailSenderImpl.setProtocol方法代码示例

本文整理汇总了Java中org.springframework.mail.javamail.JavaMailSenderImpl.setProtocol方法的典型用法代码示例。如果您正苦于以下问题:Java JavaMailSenderImpl.setProtocol方法的具体用法?Java JavaMailSenderImpl.setProtocol怎么用?Java JavaMailSenderImpl.setProtocol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.mail.javamail.JavaMailSenderImpl的用法示例。


在下文中一共展示了JavaMailSenderImpl.setProtocol方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
@PostConstruct
public void init() {

	// create new java mail sender
	mailSender = new JavaMailSenderImpl();

	// set mail sender configuration
	mailSender.setHost(host);
	mailSender.setPort(port);
	mailSender.setProtocol(protocol);
	mailSender.setUsername(username);
	mailSender.setPassword(password);

	// create java mail properties
	Properties mailProperties = new Properties();
	mailProperties.put("mail.smtp.auth", auth);
	mailProperties.put("mail.smtp.starttls.enable", starttls);
	mailProperties.put("mail.smtp.timeout", timeout);    
	mailProperties.put("mail.smtp.connectiontimeout", timeout);  

	// set java mail properties
	mailSender.setJavaMailProperties(mailProperties);
}
 
开发者ID:chrisipa,项目名称:cloud-portal,代码行数:24,代码来源:MailService.java

示例2: mailSender

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
@Bean
public JavaMailSender mailSender() {
	JavaMailSenderImpl sender = new JavaMailSenderImpl();
	sender.setHost(this.properties.getHost());
	sender.setPort(this.properties.getPort());
	sender.setUsername(this.properties.getUsername());
	sender.setPassword(this.properties.getPassword());
	sender.setProtocol(this.properties.getProtocol());
	sender.setDefaultEncoding(this.properties.getDefaultEncoding().name());
	// extra properties
	if (!this.properties.getProperties().isEmpty()) {
		Properties mailProperties = new Properties();
		mailProperties.putAll(this.properties.getProperties());
		sender.setJavaMailProperties(mailProperties);
	}
	return sender;
}
 
开发者ID:mychalvlcek,项目名称:spring-rest-skeleton,代码行数:18,代码来源:EmailConfiguration.java

示例3: javaMailSender

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
@Bean
public JavaMailSender javaMailSender() {
	JavaMailSenderImpl mailSender = new JavaMailSenderImpl();

	Properties mailProperties = new Properties();
	mailProperties.put("mail.smtp.auth", auth);
	mailProperties.put("mail.smtp.starttls.enable", starttls);
	mailSender.setJavaMailProperties(mailProperties);
	mailSender.setHost(host);
	mailSender.setPort(port);
	mailSender.setProtocol(protocol);
	mailSender.setUsername(username);
	mailSender.setPassword(password);

	return mailSender;
}
 
开发者ID:oojorgeoo89,项目名称:QuizZz,代码行数:17,代码来源:MailConfig.java

示例4: javaMailSender

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
@Bean
public JavaMailSender javaMailSender() {
    JavaMailSenderImpl mailSender = new JavaMailSenderImpl();

    Properties mailProperties = new Properties();
    mailProperties.put("mail.smtp.auth", auth);
    mailProperties.put("mail.smtp.starttls.enable", starttls);
    mailProperties.put("mail.smtp.starttls.required", startlls_required);
    mailProperties.put("mail.smtp.socketFactory.port", socketPort);
    mailProperties.put("mail.smtp.debug", debug);
    mailProperties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
    mailProperties.put("mail.smtp.socketFactory.fallback", fallback);

    mailSender.setJavaMailProperties(mailProperties);
    mailSender.setHost(host);
    mailSender.setPort(port);
    mailSender.setProtocol(protocol);
    mailSender.setUsername(username);
    mailSender.setPassword(password);
    return mailSender;
}
 
开发者ID:Exercon,项目名称:AntiSocial-Platform,代码行数:22,代码来源:MailConfiguration.java

示例5: javaMailSender

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
@Bean
public JavaMailSender javaMailSender() {
    JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
    mailSender.setHost(config.getSmtpHost());
    mailSender.setPort(config.getSmtpPort());
    mailSender.setProtocol(config.getSmtpProtocol());
    mailSender.setUsername(config.getSmtpUsername());
    mailSender.setPassword(config.getSmtpPassword());
    mailSender.setDefaultEncoding("UTF-8");
    if ("smtps".equalsIgnoreCase(config.getSmtpProtocol())) {
        Properties mailProperties = new Properties();
        mailProperties.setProperty("mail.smtps.auth", "true");
        mailProperties.setProperty("mail.smtp.ssl.enable", "true");
        mailProperties.setProperty("mail.transport.protocol", "smtps");
        mailProperties.setProperty("mail.debug", "true");
        mailProperties.setProperty("mail.mime.charset", "utf8");
        mailSender.setJavaMailProperties(mailProperties);
    }
    return mailSender;
}
 
开发者ID:mattpwest,项目名称:entelect-spring-webapp-template,代码行数:21,代码来源:MailConfig.java

示例6: createSender

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
protected JavaMailSenderImpl createSender(Map<ApplicationPropertyMailing, String> settings) {
    JavaMailSenderImpl sender = new JavaMailSenderImpl();
    sender.setProtocol(PROTOCOL);
    sender.setHost(settings.get(ApplicationPropertyMailing.HOST));
    sender.setPort(getPort(settings));
    Properties mailingProperties = new Properties();
    String login = settings.get(ApplicationPropertyMailing.LOGIN);
    if (StringUtils.isNotEmpty(login)) {
        sender.setUsername(login);
        mailingProperties.setProperty("mail.smtp.auth", "true");
        String password = settings.get(ApplicationPropertyMailing.PASSWORD);
        if (StringUtils.isNotEmpty(password)) {
            // expect non-encrypted password!
            sender.setPassword(password);
        }
    }
    mailingProperties.setProperty("mail.smtp.starttls.enable", getStartTls(settings));
    sender.setJavaMailProperties(mailingProperties);
    return sender;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:21,代码来源:SmtpMimeMessageSender.java

示例7: mailSender

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
@Bean
public JavaMailSenderImpl mailSender() {
    final JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
    javaMailSender.setHost(host);
    if (StringUtils.isNumeric(port)) {
        javaMailSender.setPort(Integer.valueOf(this.port));
    }
    javaMailSender.setUsername(username);
    javaMailSender.setPassword(password);
    javaMailSender.setProtocol(protocol);
    javaMailSender.setJavaMailProperties(loadProperties());
    return javaMailSender;
}
 
开发者ID:gravitee-io,项目名称:gravitee-management-rest-api,代码行数:14,代码来源:EmailConfiguration.java

示例8: applyProperties

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
private void applyProperties(JavaMailSenderImpl sender) {
	sender.setHost(this.properties.getHost());
	if (this.properties.getPort() != null) {
		sender.setPort(this.properties.getPort());
	}
	sender.setUsername(this.properties.getUsername());
	sender.setPassword(this.properties.getPassword());
	sender.setProtocol(this.properties.getProtocol());
	if (this.properties.getDefaultEncoding() != null) {
		sender.setDefaultEncoding(this.properties.getDefaultEncoding().name());
	}
	if (!this.properties.getProperties().isEmpty()) {
		sender.setJavaMailProperties(asProperties(this.properties.getProperties()));
	}
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:16,代码来源:MailSenderAutoConfiguration.java

示例9: javaMailSender

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
@Bean
public JavaMailSender javaMailSender() {
    JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
    Properties mailProperties = new Properties();
    mailProperties.put("mail.smtp.auth", auth);
    mailProperties.put("mail.smtp.starttls.enable", starttls);
    mailSender.setJavaMailProperties(mailProperties);
    mailSender.setHost(host);
    mailSender.setPort(port);
    mailSender.setProtocol(protocol);
    mailSender.setUsername(username);
    mailSender.setPassword(password);
    return mailSender;
}
 
开发者ID:alexgamas,项目名称:treinamento-spring-boot,代码行数:15,代码来源:MailConfiguration.java

示例10: javaMailSender

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
@Bean
public JavaMailSender javaMailSender() {
	JavaMailSenderImpl mailSender = new org.springframework.mail.javamail.JavaMailSenderImpl();
	mailSender.setHost(config.getEmailHost());
	mailSender.setPort(config.getEmailPort());
	String emailUsername = config.getEmailUsername();
	if (emailUsername!=null) {
		mailSender.setUsername(emailUsername);
	}
	String emailPassword = config.getEmailPassword();
	if (emailPassword!=null) {
		mailSender.setPassword(emailPassword);
	}
	String emailProtocol = config.getEmailProtocol();
	if (emailProtocol!=null) {
		mailSender.setProtocol(emailProtocol);
	}
	Properties emailProperties = config.getEmailProperties();
	if (emailProperties!=null) {
		mailSender.setJavaMailProperties(emailProperties);
	}
	return mailSender;
}
 
开发者ID:xtianus,项目名称:yadaframework,代码行数:24,代码来源:YadaAppConfig.java

示例11: buildMailSender

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
private JavaMailSender buildMailSender(AlerterConfig config) {
    JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
    Properties mailProperties = new Properties();
    mailProperties.put("mail.smtp.auth", config.getSmtpAuth());
    mailProperties.put("mail.smtp.starttls.enable", "true");

    mailSender.setJavaMailProperties(mailProperties);
    mailSender.setHost(config.getHost());
    mailSender.setPort(config.getPort());
    mailSender.setProtocol(config.getProtocol());
    mailSender.setUsername(config.getUsername());
    mailSender.setPassword(config.getPassword());
    return mailSender;
}
 
开发者ID:balamaci,项目名称:muninn,代码行数:15,代码来源:MailAlerter.java

示例12: createInstance

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
@Override
protected  Object createInstance() throws Exception {
    // Retrieve "mail.*" properties from the configuration system and construct a Properties object
	Properties properties = new Properties();
	Properties configProps = ConfigContext.getCurrentContextConfig().getProperties();
	LOG.debug("createInstance(): collecting mail properties.");
	for (Object keyObj : configProps.keySet()) {
	    if (keyObj instanceof String) {
	    	String key = (String)keyObj;
	    	if (key.startsWith(MAIL_PREFIX)){
	    		properties.put(key, configProps.get(key));
	    	}
	    }
	}
	
	// Construct an appropriate Java Mail Session
	// If username and password properties are found, construct a Session with SMTP authentication
	String username = properties.getProperty(USERNAME_PROPERTY);
	String password = properties.getProperty(PASSWORD_PROPERTY);
	if (username != null && password != null) {
		mailSession = Session.getInstance(properties, new SimpleAuthenticator(username, password));
		LOG.info("createInstance(): Initializing mail session using SMTP authentication.");
	} else {
		mailSession = Session.getInstance(properties);
		LOG.info("createInstance(): Initializing mail session. No SMTP authentication.");
	}
	
	// Construct and return a Spring Java Mail Sender
	JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
	LOG.debug("createInstance(): setting SMTP host.");
	mailSender.setHost(properties.getProperty(HOST_PROPERTY));
	if (properties.getProperty(PORT_PROPERTY) != null) {
		LOG.debug("createInstance(): setting SMTP port.");
		int smtpPort = Integer.parseInt(properties.getProperty(PORT_PROPERTY).trim());
		mailSender.setPort(smtpPort);
	}
       String protocol = properties.getProperty(PROTOCOL_PROPERTY);
       if (StringUtils.isNotBlank(protocol)) {
           LOG.debug("createInstance(): setting mail transport protocol = " + protocol);
           mailSender.setProtocol(protocol);
       }
	mailSender.setSession(mailSession);
	
	LOG.info("createInstance(): Mail Sender Factory Bean initialized.");
	return mailSender;
   }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:47,代码来源:MailSenderFactoryBean.java

示例13: emailService

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
@Bean(name="emailService")
protected EmailService emailService() throws UnsupportedEncodingException {
    JavaMailSenderImpl sender = new JavaMailSenderImpl();

    int port = smtpProperties.getPort();

    if (port > 0) {
        sender.setPort(port);
    }
    sender.setProtocol(smtpProperties.getProtocol());
    sender.setHost(smtpProperties.getHost());

    Properties mailProps = new Properties();

    if (!StringUtils.isBlank(smtpProperties.getUsername()) && !StringUtils.isBlank(smtpProperties.getPassword()) ) {
        sender.setUsername(smtpProperties.getUsername());
        sender.setPassword(smtpProperties.getPassword());
        mailProps.setProperty(String.format("mail.%s.auth", smtpProperties.getProtocol()), "true");
    }
    else {
        mailProps.setProperty(String.format("mail.%s.auth", smtpProperties.getProtocol()), "false");
    }

    if("smtps".equals(smtpProperties.getProtocol())) {
        mailProps.setProperty("mail.smtps.ssl.enable", "true");
    }

    mailProps.setProperty("mail.smtps.connectiontimeout", Integer.toString(smtpProperties.getTimeout()));

    if (smtpProperties.isDebug()) {
        mailProps.setProperty("mail.debug", "true");
        System.setProperty("mail.socket.debug", "true");
    }

    sender.setJavaMailProperties(mailProps);

    return new EmailService(sender, smtpProperties.getEmail(), smtpProperties.getEmailName());
}
 
开发者ID:trustedanalytics,项目名称:user-management,代码行数:39,代码来源:InvitationsConfig.java

示例14: fixAuth

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
private void fixAuth(JavaMailSenderImpl javaMailSender, Properties props) {
	if (javaMailSender.getPort() == 465) {
		props.put("mail.smtp.auth", true);
		props.put("mail.smtp.starttls.enable", false);
		props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
		props.put("mail.smtp.socketFactory.fallback", false);
		props.put("mail.debug", true);
		javaMailSender.setProtocol("smtp");
	}
}
 
开发者ID:jirkapinkas,项目名称:sitemonitoring-production,代码行数:11,代码来源:SendEmailService.java

示例15: initMailer

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
@PostConstruct
   private void initMailer(){

mailSender = new JavaMailSenderImpl();

mailSender.setHost(mailSenderHost);
mailSender.setProtocol(mailSenderProtocol);	
mailSender.setPort(Integer.parseInt(mailSenderPort));
mailSender.setUsername(mailSenderUsername);
mailSender.setPassword(mailSenderPassword);


to = mailSenderTo.split(",");
if(StringUtils.isNotBlank(mailSenderDebugTo))
    debugTo = mailSenderDebugTo.split(",");

// Advanced section
Properties prop = EnvUtil.getConfigAsProperty();
Properties javaMail = new Properties();
for( Object key : prop.keySet()) {
    String sk = (String) key;
    if (StringUtils.startsWith(sk, "mail.")){
	javaMail.put(sk, prop.getProperty(sk));
    }
}

mailSender.setJavaMailProperties(javaMail);
log.info("mailSender configured without errors. Email enabled:"+mailsenderEnable);

   }
 
开发者ID:renatodelgaudio,项目名称:awsroute53,代码行数:31,代码来源:Mailer.java


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