简单的发送邮件(resty-mail)
1. 配置MailPlugin插件
public void configPlugin(PluginLoader pluginLoader) {
MailPlugin mailPlugin = new MailPlugin();
pluginLoader.add(mailPlugin);
}
2. 发送普通的文本邮件
SimpleEmail simpleEmail=MailSender.getSimpleEmail("测试主题","测试内容","[email protected]");
simpleEmail.send();
MailSender.sendText("测试主题","测试内容","[email protected]");
3. 发送html邮件
HtmlEmail htmlEmail = MailSender.getHtmlEmail("测试", "[email protected]");
htmlEmail.setHtmlMsg("<a href='www.dreampie.cn'>Dreampie</a>");
htmlEmail.send();
MailSender.sendHtml("测试主题","<a href='www.dreampie.cn'>Dreampie</a>","[email protected]");
4. 发送附件邮件
EmailAttachment attachment =new EmailAttachment();
attachment.setPath("c:/234.jpg");
attachment.setDisposition(EmailAttachment.ATTACHMENT);
attachment.setDescription("a.jpg");
attachment.setName("a.jpg");
MultiPartEmail multiPartEmail=MailSender.getMultiPartEmail("测试主题","测试内容",attachment,"[email protected]");
multiPartEmail.send();
MailSender.sendAttachment("测试主题","测试内容",attachment,"[email protected]");