package cn.iselab.mooctest.user.configure;

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

/**
 * @Description: 作用描述
 * @Author: xuexb
 * @CreateDate: 18-12-25$ 下午9:45$
 */
@Configuration
public class MailConfiguration {

    @Autowired
    private MailProperties mailProperties;

    @Bean
    public JavaMailSender getJavaMailSender(){
        JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
        javaMailSender.setProtocol("smtp");
        javaMailSender.setHost(mailProperties.getHost());
        javaMailSender.setUsername(mailProperties.getUsername());
        javaMailSender.setPassword(mailProperties.getPassword());
//        javaMailSender.setDefaultEncoding(mailProperties.getDefault_encoding());
        javaMailSender.setDefaultEncoding("UTF-8");

        return javaMailSender;
    }

}
