All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jiangkedev.email.EmailConfig Maven / Gradle / Ivy

The newest version!
package com.jiangkedev.email;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;

import java.util.Properties;

/**
 * author:bazz jiang
 * date:Create in 2018-07-27
 * email:[email protected]
 */
@Configuration
public class EmailConfig {
    @Bean
    public JavaMailSender sohuMailSender(){
        //需要去搜狐邮箱开启服务
        JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
        mailSender.setHost("smtp.sohu.com");
        mailSender.setPort(25);
        mailSender.setUsername("[email protected]");
        mailSender.setPassword("");

        Properties props = mailSender.getJavaMailProperties();
        props.put("mail.transport.protocol", "smtp");
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.starttls.enable", "true");
        props.put("mail.debug", "true");
        return mailSender;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy