當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。