package com.xjrsoft.config;

import cn.hutool.extra.mail.MailAccount;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 邮箱账户配置类
 * @Author: tzx
 * @Date: 2022/10/27 10:58
 */
@Configuration
@Slf4j
public class MailAccountConfig {
    @Value("${xjrsoft.email.host}")
    public String host;

    @Value("${xjrsoft.email.port}")
    public Integer port;

    @Value("${xjrsoft.email.auth}")
    public Boolean auth;

    @Value("${xjrsoft.email.from}")
    public String from;

    @Value("${xjrsoft.email.user}")
    public String user;

    @Value("${xjrsoft.email.pass}")
    public String pass;


    @Bean
    public MailAccount mailAccount(){
        log.info("------------mail account config init---------------");
        MailAccount account = new MailAccount();
        account.setHost(host);
        account.setPort(port);
        account.setAuth(auth);
        account.setFrom(from);
        account.setUser(user);
        account.setPass(pass);
        return account;
    }
}
