Skip to content

Commit

Permalink
feat: mail sender
Browse files Browse the repository at this point in the history
  • Loading branch information
chengzi committed Jul 14, 2021
1 parent 2262b3b commit 23dbfb8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ public Object meiRiYiWen() {
model.put("items", items);
Template template = freeMarkerConfig.getConfiguration().getTemplate("meiArticle.ftl");
String content = FreeMarkerTemplateUtils.processTemplateIntoString(template, model);
mailSender.sendMultipartMailV2("[email protected]", subject, content);
mailSender.sendMultipartMailV2("[email protected]", subject + "@每日一文", content);
mailSender.sendMultipartMailV2("chengzi12130[email protected]", "chengzi12130@gmail.com", subject, content);
mailSender.sendMultipartMailV2("[email protected]", "[email protected]", subject + "@每日一文", content);
log.info("[[title={}]], spider send mail:{}", "meiRiYiWen", subject);
return model;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/chengzi/book2read/service/MailSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ public void sendMultipartMail(String subject, String content) {
* @param subject mail subject
* @param htmlString html string
*/
public void sendMultipartMailV2(String email,String subject, String htmlString) {
public void sendMultipartMailV2(String fromMail, String toEmail, String subject, String htmlString) {
log.info("[[title={}]],subject:{}, start send mail", "sendMultipartMailV2", subject);
try {
Session session = Session.getDefaultInstance(new Properties(), null);
Message msg = new MimeMessage(session);
InternetAddress from = new InternetAddress("[email protected]", "daily article spider");
InternetAddress to = new InternetAddress(email, "daily favor article");
InternetAddress from = new InternetAddress(fromMail, "daily article spider");
InternetAddress to = new InternetAddress(toEmail, "daily favor article");
msg.setFrom(from);
msg.addRecipient(Message.RecipientType.TO, to);
msg.setSubject(subject);
Expand Down

0 comments on commit 23dbfb8

Please sign in to comment.