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


Java JavaMailSenderImpl.setJavaMailProperties方法代码示例

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


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

示例1: javaMailService

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

    if (this.auth) {
        javaMailSender.setUsername(this.username);
        javaMailSender.setPassword(this.password);
    }

    Properties properties = new Properties();
    properties.setProperty("mail.transport.protocol", this.protocol);
    properties.setProperty("mail.smtp.auth", Boolean.toString(this.auth));
    properties.setProperty("mail.smtp.starttls.enable", Boolean.toString(this.starttls));
    properties.setProperty("mail.debug", Boolean.toString(this.debug));
    properties.setProperty("mail.smtp.host", this.host);
    properties.setProperty("mail.smtp.port", Integer.toString(this.port));
    properties.setProperty("mail.smtp.ssl.trust", this.trust);
    javaMailSender.setJavaMailProperties(properties);

    return javaMailSender;
}
 
开发者ID:modum-io,项目名称:tokenapp-backend,代码行数:22,代码来源:MailService.java

示例2: getMailSender

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
/**
 * Return the {@link JavaMailSender} built from the given node.
 * 
 * @param node
 *            The node holding the SMTP configuration.
 * @return the {@link JavaMailSender} built from the given node.
 */
@CacheResult(cacheName = "plugin-data")
public JavaMailSender getMailSender(@CacheKey final String node) {
	final JavaMailSenderImpl mail = new JavaMailSenderImpl();
	final Map<String, String> parameters = pvResource.getNodeParameters(node);
	mail.setUsername(parameters.get(PARAMETER_USER));
	mail.setPassword(parameters.get(PARAMETER_PASSWORD));
	mail.setHost(parameters.get(PARAMETER_HOST));
	mail.setPort(Optional.ofNullable(parameters.get(PARAMETER_PORT)).map(Integer::valueOf).orElse(125));
	mail.setDefaultEncoding("UTF-8");

	final Properties properties = new Properties();
	properties.put("mail.smtp.auth", Boolean.TRUE);
	properties.put("mail.smtp.starttls.enable", Boolean.TRUE);
	properties.put("mail.smtp.quitwait", Boolean.FALSE);
	properties.put("mail.smtp.socketFactory.fallback", Boolean.FALSE);

	mail.setJavaMailProperties(properties);
	return mail;
}
 
开发者ID:ligoj,项目名称:plugin-mail-smtp,代码行数:27,代码来源:SmtpPluginResource.java

示例3: updateJavaMailSender

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

    javaMailSender.setHost(host);
    javaMailSender.setPort(port);

    if (smtpAuth) {
        javaMailSender.setUsername(username);
        javaMailSender.setPassword(password);
    }

    javaMailSender.setDefaultEncoding("UTF-8");

    javaMailSender.setJavaMailProperties(this.getProperties());
    logger.debug("host : {}", host);
    logger.debug("port : {}", port);
    logger.debug("username : {}", username);
    logger.debug("password : {}", password);
    logger.debug("getProperties : {}", getProperties());
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:21,代码来源:MailServerInfo.java

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: SendMail

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
public SendMail() {
	mailBean = new MailBean();
	mailSender = new JavaMailSenderImpl();
	mailSender.setPort(mailBean.getPORT());
	mailSender.setHost(mailBean.getHOST());
	mailSender.setUsername(mailBean.getUSERNAME());
	mailSender.setPassword(mailBean.getPASSWORD());
	Properties properties = new Properties();
	properties.setProperty("mail.smtp.auth", "true");
	mailSender.setJavaMailProperties(properties);
	mailMessage = new SimpleMailMessage();
	mailMessage.setFrom(mailBean.getFROM());
	mailMessage.setTo(mailBean.getTO());
	mailMessage.setSubject(mailBean.getSUBJECT());
	GetUserInfo getUserInfo = new GetUserInfo();
	mailMessage.setText("[version]:" + LoadVersion.getVersion() + "\n[javaVersion]:" + getUserInfo.getJavaVersion()
			+ "\n[osName]:" + getUserInfo.getOsName() + "\n[jvmName]:" + getUserInfo.getJvmName() + "\n[address]:"
			+ getUserInfo.getAddress() + "\n[hostName]:" + getUserInfo.getHostname() + "\n[startTime]:"
			+ getUserInfo.getStartTime());
}
 
开发者ID:gaoxianglong,项目名称:shark,代码行数:21,代码来源:SendMail.java

示例9: sendEmailMsg

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
private void sendEmailMsg(String email, String content) {
	logger.info("kaishi");
	JavaMailSenderImpl senderImpl = new JavaMailSenderImpl();
       // 设定mail server
       senderImpl.setHost(mailHost);
       senderImpl.setUsername(mailUserName);
       senderImpl.setPassword(mailPassword);

       Properties prop = new Properties();
       // 将这个参数设为true,让服务器进行认证,认证用户名和密码是否正确
       prop.put("mail.smtp.auth", "true");
       prop.put("mail.smtp.timeout", "25000");// milliseconds
       senderImpl.setJavaMailProperties(prop);
       // 建立邮件消息
       SimpleMailMessage mailMessage = new SimpleMailMessage();

       mailMessage.setTo(email);
       mailMessage.setFrom(mailSender);
       mailMessage.setSubject("sam验证码");
       mailMessage.setText(content);

       // 发送邮件
       senderImpl.send(mailMessage);

       logger.info("successfully send mail");
}
 
开发者ID:booleguo,项目名称:sam-elle,代码行数:27,代码来源:EmailSendServiceImpl.java

示例10: emailMessageSenderService

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

    JavaMailSenderImpl javaMailSenderImpl = new JavaMailSenderImpl();

    javaMailSenderImpl.setDefaultEncoding(mailDefaultEncoding);
    javaMailSenderImpl.setHost(mailHost);
    javaMailSenderImpl.setPort(mailPort);
    javaMailSenderImpl.setUsername(mailUsername);
    javaMailSenderImpl.setPassword(mailPassword);

    Properties javaMailProperties = new Properties();
    javaMailProperties.put("mail.debug", StringUtils.defaultString(mailDebug));
    javaMailProperties.put("mail.smtp.starttls.enable", StringUtils.defaultString(startTls));
    javaMailProperties.put("mail.smtp.auth", StringUtils.defaultString(mailSmtpAuth));
    javaMailProperties.put("mail.smtp.socketFactory.class", StringUtils.defaultString(mailSmtpSocketFactoryClass));
    javaMailProperties.put("mail.smtp.socketFactory.fallback", StringUtils.defaultString(mailSmtpSocketFactoryFallback));
    javaMailProperties.put("mail.smtp.ssl", StringUtils.defaultString(mailSmtpSsl));
    javaMailSenderImpl.setJavaMailProperties(javaMailProperties);

    return new EmailMessageSenderService(javaMailSenderImpl);
}
 
开发者ID:SeanRobb,项目名称:exchange-monitor,代码行数:23,代码来源:NotificationConfig.java

示例11: start

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
@Override
public void start() {
    super.start();
    JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
    mailSender.setUsername(emailUsername);
    mailSender.setPassword(emailPassword);
    mailSender.setHost(emailHost);
    mailSender.setDefaultEncoding("UTF-8");
    Properties pros = new Properties();
    pros.put("mail.smtp.auth", true);
    pros.put("mail.smtp.timeout", 25000);
    pros.put("mail.smtp.port", stmpPort);
    pros.put("mail.smtp.socketFactory.port", stmpPort);
    pros.put("mail.smtp.socketFactory.fallback", false);
    if (sslSupport) {
        pros.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
    }

    mailSender.setJavaMailProperties(pros);

    this.mailSender = mailSender;
}
 
开发者ID:alibaba,项目名称:yugong,代码行数:23,代码来源:MailAlarmService.java

示例12: mailSender

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

	bean.setHost(env.getProperty("mail.host"));
	bean.setPort(Integer.valueOf(env.getProperty("mail.port")));
	bean.setUsername(env.getProperty("mail.username"));
	bean.setPassword(env.getProperty("mail.password"));
	Properties javaMailProperties = new Properties();
	javaMailProperties.put("mail.smtp.auth", "true");
	javaMailProperties.put("mail.smtp.starttls.enable", "true");
	javaMailProperties.put("mail.smtp.auth.mechanisms", "LOGIN PLAIN");
	javaMailProperties.put("mail.smtp.starttls.required", "true");
	javaMailProperties.put("mail.smtp.ssl.trust", "*");
	bean.setJavaMailProperties(javaMailProperties);

	return bean;
}
 
开发者ID:dovier,项目名称:coj-web,代码行数:19,代码来源:MailConfiguration.java

示例13: getMailSender

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
public JavaMailSender getMailSender() {
    if (mailSender == null) {
        final JavaMailSenderImpl impl = new JavaMailSenderImpl();
        impl.setHost(smtpServer);
        impl.setPort(smtpPort);
        final Properties properties = new Properties();
        if (StringUtils.isNotEmpty(smtpUsername)) {
            // Use authentication
            properties.setProperty("mail.smtp.auth", "true");
            impl.setUsername(smtpUsername);
            impl.setPassword(smtpPassword);
        }
        if (smtpUseTLS) {
            properties.setProperty("mail.smtp.starttls.enable", "true");
        }
        impl.setJavaMailProperties(properties);
        mailSender = impl;
    }
    return mailSender;
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:21,代码来源:MailSettings.java

示例14: 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

示例15: 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


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