1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
| @Async("asyncExecutor") public void sendUserDisabledNotification(String toEmail, String nickname, String username) { try { MimeMessage message = mailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message, true, "UTF-8");
helper.setFrom(from); helper.setTo(toEmail); helper.setSubject("【云梦泽的个人博客】您的账号已被禁用");
String htmlContent = buildUserDisabledNotificationHtml(nickname, username); helper.setText(htmlContent, true);
mailSender.send(message); } catch (MessagingException e) { e.printStackTrace(); } }
@Async("asyncExecutor") public void sendUserEnabledNotification(String toEmail, String nickname, String username) { try { MimeMessage message = mailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message, true, "UTF-8");
helper.setFrom(from); helper.setTo(toEmail); helper.setSubject("【云梦泽的个人博客】您的账号已恢复正常使用");
String htmlContent = buildUserEnabledNotificationHtml(nickname, username); helper.setText(htmlContent, true);
mailSender.send(message); } catch (MessagingException e) { e.printStackTrace(); } }
private String buildUserDisabledNotificationHtml(String nickname, String username) { return "<!DOCTYPE html>" + "<html>" + "<head>" + " <meta charset=\"UTF-8\">" + " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">" + "</head>" + "<body style=\"margin: 0; padding: 0; background: linear-gradient(135deg, #a5dff9 0%, #008c9e 100%); font-family: 'Segoe UI', Arial, sans-serif;\">" + " <table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"padding: 40px 20px;\">" + " <tr>" + " <td align=\"center\">" + " <table width=\"600\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-color: #f5fffa; border-radius: 12px; box-shadow: 0 12px 15px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.19); overflow: hidden;\">" + " <tr>" + " <td style=\"background: rgb(125, 182, 191); padding: 40px 30px; text-align: center;\">" + " <h1 style=\"color: #2c3e50; margin: 0; font-size: 28px; font-weight: 600; letter-spacing: 1px;\">云梦泽的个人博客</h1>" + " <p style=\"color: #546e7a; margin: 10px 0 0 0; font-size: 14px;\">账号状态变更通知</p>" + " </td>" + " </tr>" + " <tr>" + " <td style=\"padding: 50px 40px;\">" + " <h2 style=\"color: #3c4858; margin: 0 0 20px 0; font-size: 22px; font-weight: 600;\">您好," + (StringUtils.hasText(nickname) ? nickname : username) + "!</h2>" + " <p style=\"color: #718096; line-height: 1.8; margin: 0 0 30px 0; font-size: 15px;\">" + " 由于您在平台中的不正当行为,我们已将您的账号进行封禁处理,您此后不允许使用该账号在我们平台上登录。 " + " </p>" + " <div style=\"background: linear-gradient(135deg, #f8f9fa 0%, #e8f4f8 100%); border-left: 4px solid #f44336; border-radius: 8px; padding: 25px; margin: 30px 0; box-shadow: 0 2px 8px rgba(244,67,54,0.1);\">" + " <p style=\"color: #3c4858; line-height: 1.8; margin: 0 0 15px 0; font-size: 15px; font-weight: 600;\">" + " (╯-_-)╯╧╧ 账号被封禁" + " </p>" + " <p style=\"color: #718096; line-height: 1.8; margin: 0; font-size: 14px;\">" + " 您的账号(" + username + ")当前状态:<strong style=\"color: #f44336;\">已被禁用</strong>" + " </p>" + " </div>" + " </td>" + " </tr>" + " <tr>" + " <td style=\"background: linear-gradient(135deg, #f8f9fa 0%, #eaecef 100%); padding: 30px; text-align: center; border-top: 1px solid #eaecef;\">" + " <p style=\"color: #718096; margin: 0 0 10px 0; font-size: 13px;\">此邮件由系统自动发送,请勿直接回复</p>" + " <p style=\"color: #a7a9ad; margin: 0; font-size: 12px;\">© " + LocalDate.now().getYear() + " 云梦泽的个人博客 · All rights reserved</p>" + " </td>" + " </tr>" + " </table>" + " </td>" + " </tr>" + " </table>" + "</body>" + "</html>"; }
private String buildUserEnabledNotificationHtml(String nickname, String username) { return "<!DOCTYPE html>" + "<html>" + "<head>" + " <meta charset=\"UTF-8\">" + " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">" + "</head>" + "<body style=\"margin: 0; padding: 0; background: linear-gradient(135deg, #a5dff9 0%, #008c9e 100%); font-family: 'Segoe UI', Arial, sans-serif;\">" + " <table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"padding: 40px 20px;\">" + " <tr>" + " <td align=\"center\">" + " <table width=\"600\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-color: #f5fffa; border-radius: 12px; box-shadow: 0 12px 15px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.19); overflow: hidden;\">" + " <tr>" + " <td style=\"background: rgb(125, 182, 191); padding: 40px 30px; text-align: center;\">" + " <h1 style=\"color: #2c3e50; margin: 0; font-size: 28px; font-weight: 600; letter-spacing: 1px;\">云梦泽的个人博客</h1>" + " <p style=\"color: #546e7a; margin: 10px 0 0 0; font-size: 14px;\">账号解封通知</p>" + " </td>" + " </tr>" + " <tr>" + " <td style=\"padding: 50px 40px;\">" + " <h2 style=\"color: #3c4858; margin: 0 0 20px 0; font-size: 22px; font-weight: 600;\">您好," + (StringUtils.hasText(nickname) ? nickname : username) + "!</h2>" + " <p style=\"color: #718096; line-height: 1.8; margin: 0 0 30px 0; font-size: 15px;\">" + " 您的账号已解封,您可以继续在平台中使用该账号。" + " </p>" + " <div style=\"background: linear-gradient(135deg, #f8f9fa 0%, #e8f4f8 100%); border-left: 4px solid #52c41a; border-radius: 8px; padding: 25px; margin: 30px 0; box-shadow: 0 2px 8px rgba(82,196,26,0.1);\">" + " <p style=\"color: #3c4858; line-height: 1.8; margin: 0 0 15px 0; font-size: 15px; font-weight: 600;\">" + " - ̗̀ ෆ( ˶’ᵕ’˶)ෆ ̖́- 账号解封" + " </p>" + " <p style=\"color: #718096; line-height: 1.8; margin: 0; font-size: 14px;\">" + " 您的账号(" + username + ")当前状态:<strong style=\"color: #52c41a;\">已恢复正常使用</strong>" + " </p>" + " </div>" + " </td>" + " </tr>" + " <tr>" + " <td style=\"background: linear-gradient(135deg, #f8f9fa 0%, #eaecef 100%); padding: 30px; text-align: center; border-top: 1px solid #eaecef;\">" + " <p style=\"color: #718096; margin: 0 0 10px 0; font-size: 13px;\">此邮件由系统自动发送,请勿直接回复</p>" + " <p style=\"color: #a7a9ad; margin: 0; font-size: 12px;\">© " + LocalDate.now().getYear() + " 云梦泽的个人博客 · All rights reserved</p>" + " </td>" + " </tr>" + " </table>" + " </td>" + " </tr>" + " </table>" + "</body>" + "</html>"; }
|