當前位置: 首頁>>代碼示例>>Java>>正文


Java JavaMailSenderImpl.setUsername方法代碼示例

本文整理匯總了Java中org.springframework.mail.javamail.JavaMailSenderImpl.setUsername方法的典型用法代碼示例。如果您正苦於以下問題:Java JavaMailSenderImpl.setUsername方法的具體用法?Java JavaMailSenderImpl.setUsername怎麽用?Java JavaMailSenderImpl.setUsername使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.mail.javamail.JavaMailSenderImpl的用法示例。


在下文中一共展示了JavaMailSenderImpl.setUsername方法的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: 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

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

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

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

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

示例13: mailSender

import org.springframework.mail.javamail.JavaMailSenderImpl; //導入方法依賴的package包/類
@Bean
public JavaMailSenderImpl mailSender() {
    JavaMailSenderImpl sender = new JavaMailSenderImpl();

    sender.setUsername("[email protected]");
    sender.setPassword("wang700327");

    sender.setHost("smtp.126.com");
    sender.setPort(25);

    Properties prop = new Properties();
    prop.put("mail.transport.protocol", "smtp");
    prop.put("mail.smtp.auth", true);
    prop.put("mail.smtp.starttls.enable", true);
    sender.setJavaMailProperties(prop);

    return sender;
}
 
開發者ID:wswenyue,項目名稱:taolijie,代碼行數:19,代碼來源:MailTest.java

示例14: init

import org.springframework.mail.javamail.JavaMailSenderImpl; //導入方法依賴的package包/類
@PostConstruct
public void init()
{
    Settings settings = settingsService.getSettings();
    JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();

    if (!settings.getSmtpServer().isEmpty())
    {
        javaMailSender.setHost(settings.getSmtpServer());
    }
    if (!settings.getSmtpPort().isEmpty())
    {
        javaMailSender.setPort(Integer.parseInt(settings.getSmtpPort()));
    }

    javaMailSender.setUsername(settings.getStmpUser());
    javaMailSender.setPassword(settings.getStmpPassword());

    javaMailSender.setJavaMailProperties(getMailProperties(settings));

    sender = javaMailSender;
}
 
開發者ID:d0k1,項目名稱:jsflight,代碼行數:23,代碼來源:EmailNotificationService.java

示例15: mailSender

import org.springframework.mail.javamail.JavaMailSenderImpl; //導入方法依賴的package包/類
@Bean
@Autowired
@ConditionalOnProperty(name = MAIL_SERVICE_PROPERTY, havingValue = "realEmailService")
public JavaMailSender mailSender(@Value("${mail.host}") String host,
    @Value("${mail.port}") String port,
    @Value("${mail.username}") String username,
    @Value("${mail.password}") String password) {

    JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
    javaMailSender.setHost(host);
    javaMailSender.setPort(Integer.valueOf(port));
    javaMailSender.setUsername(username);
    javaMailSender.setPassword(password);

    return javaMailSender;
}
 
開發者ID:Contargo,項目名稱:iris,代碼行數:17,代碼來源:EmailConfig.java


注:本文中的org.springframework.mail.javamail.JavaMailSenderImpl.setUsername方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。