org.springframework.boot.autoconfigure.mail.MailProperties Java Examples

The following examples show how to use org.springframework.boot.autoconfigure.mail.MailProperties. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MailSenderFactory.java    From halo with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Get mail sender.
 *
 * @param mailProperties mail properties must not be null
 * @return java mail sender
 */
@NonNull
public JavaMailSender getMailSender(@NonNull MailProperties mailProperties) {
    Assert.notNull(mailProperties, "Mail properties must not be null");

    // create mail sender
    JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
    // set properties
    setProperties(mailSender, mailProperties);

    return mailSender;
}
 
Example #2
Source File: MailSenderFactory.java    From halo with GNU General Public License v3.0 5 votes vote down vote up
private void setProperties(@NonNull JavaMailSenderImpl mailSender, @NonNull MailProperties mailProperties) {
    mailSender.setHost(mailProperties.getHost());
    mailSender.setPort(mailProperties.getPort());
    mailSender.setUsername(mailProperties.getUsername());
    mailSender.setPassword(mailProperties.getPassword());
    mailSender.setProtocol(mailProperties.getProtocol());
    mailSender.setDefaultEncoding(mailProperties.getDefaultEncoding().name());

    if (!CollectionUtils.isEmpty(mailProperties.getProperties())) {
        Properties properties = new Properties();
        properties.putAll(mailProperties.getProperties());
        mailSender.setJavaMailProperties(properties);
    }
}
 
Example #3
Source File: DefaultExUrlProvider.java    From tx-lcn with Apache License 2.0 5 votes vote down vote up
public DefaultExUrlProvider(@Autowired(required = false) JavaMailSender javaMailSender,
                            @Autowired(required = false) MailProperties mailProperties,
                            @Autowired TxManagerConfig txManagerConfig) {
    this.javaMailSender = javaMailSender;
    this.mailProperties = mailProperties;
    Objects.requireNonNull(txManagerConfig, "tx-manager config can't be null.");

    // ujued's email can be ignored.
    if (Objects.isNull(javaMailSender)) {
        if (txManagerConfig.getExUrl().contains("[email protected]")) {
            txManagerConfig.setExUrlEnabled(false);
        }
    }
}
 
Example #4
Source File: OghamJavaMailConfiguration.java    From ogham with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(SpringMailConfigurer.class)
public SpringMailConfigurer springMailConfigurer(
		@Autowired(required=false) OghamJavaMailProperties properties,
		@Autowired(required=false) MailProperties springProperties) {
	return new SpringMailConfigurer(properties, springProperties);
}
 
Example #5
Source File: SpringMailConfigurer.java    From ogham with Apache License 2.0 4 votes vote down vote up
public SpringMailConfigurer(OghamJavaMailProperties properties, MailProperties springMailProperties) {
	super();
	this.properties = properties;
	this.springMailProperties = springMailProperties;
}