-
Notifications
You must be signed in to change notification settings - Fork 18
minsx framework common mail
Joker edited this page Apr 4, 2018
·
2 revisions
- 整合阿里/腾讯/网易/谷歌等各大企业邮箱及个人邮箱服务器配置
- 仅需给定用户名与密码即可完成邮箱服务器配置
- 可根据需要选择是否开启SSL发送邮件
- 支持普通文本邮件
- 支持HTML邮件
- 支持任意附件邮件
- 支持批量发送邮件
- 内置系统模板
- 可自定义模板
import com.minsx.framework.common.mail.MailSender;
import com.minsx.framework.common.mail.MailSenderFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class EmailConfig {
@Bean
public MailSender getMailSender() {
return MailSenderFactory.getTencentEnterpriseSSLSender("yourUsername", "yourPassword");
}
}
import com.minsx.framework.common.mail.MailSender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class MailUtil {
@Autowired
MailSender mailSender;
public void sendMail(String to, String title, String content) {
mailSender.sendSimpleMail(to,title,content);
}
}
import com.minsx.framework.common.mail.MailSender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@Service
public class MailUtil {
@Autowired
MailSender mailSender;
public Boolean sendMail(String to, String username, String title, String content) {
Boolean isSuccess = true;
Map<String, Object> params = new HashMap<>();
params.put("headerLogo", "https://image.minsx.com/pic/minsx/logo/LogoOfWhite.png");
params.put("footerLogo", "https://image.minsx.com/pic/minsx/logo/logoSuperGray.png");
params.put("webSite", "https://www.minsx.com/");
params.put("webName", "米斯云平台");
params.put("welcome", String.format("尊敬的%s:", username));
params.put("content", content);
params.put("company", "米斯云平台");
params.put("remind", "该邮件由米斯云平台系统发出,请勿直接回复!");
params.put("copyRight", "如果您有任何问题,请及时联系我们:\nEmail: support@minsx.com\nCopyright © 2016-2017 minsx.com All rights reserved.");
params.put("date", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
try {
mailSender.sendSysTemplateMail(to, title, params);
} catch (Exception e) {
e.printStackTrace();
isSuccess = false;
}
return isSuccess;
}
}
- POM引入:
<dependency>
<groupId>com.minsx</groupId>
<artifactId>minsx-framework-common-mail</artifactId>
<version>1.0.0</version>
</dependency>
Minsx-framework Apache License Version 2.0 http://www.apache.org/licenses/
项目文档
- Minsx-framework-common
- Minsx-framework-common-basic
- Minsx-framework-common-excel
- Minsx-framework-common-mail
- Minsx-framework-common-shell
- Minsx-framework-security
联系方式
- Email:support@minsx.com
- Git:github.com/MinsxCloud
- Web:www.minsx.com