feat(mail):
1. add email
This commit is contained in:
12
pom.xml
12
pom.xml
@@ -19,10 +19,10 @@
|
|||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
|
||||||
<!-- Docker仓库服务配置 -->
|
<!-- Docker仓库服务配置 -->
|
||||||
<docker.registry.url>192.168.0.188</docker.registry.url>
|
<docker.registry.url>192.168.31.132:8888</docker.registry.url>
|
||||||
<docker.username>admin</docker.username>
|
<docker.username>admin</docker.username>
|
||||||
<docker.password>admin12345</docker.password>
|
<docker.password>Harbor11aabc</docker.password>
|
||||||
<docker.namespace>blade</docker.namespace>
|
<docker.namespace>library</docker.namespace>
|
||||||
<docker.fabric.version>0.42.0</docker.fabric.version>
|
<docker.fabric.version>0.42.0</docker.fabric.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
@@ -245,6 +245,12 @@
|
|||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-mail</artifactId>
|
||||||
|
<version>3.2.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -0,0 +1,167 @@
|
|||||||
|
package org.springblade.modules.kiosk.service;
|
||||||
|
|
||||||
|
import jakarta.mail.MessagingException;
|
||||||
|
import jakarta.mail.internet.MimeMessage;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.mail.javamail.JavaMailSender;
|
||||||
|
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class EmailService {
|
||||||
|
|
||||||
|
private final JavaMailSender mailSender;
|
||||||
|
|
||||||
|
private static final String FROM_EMAIL = "info@memoryblock.com.au";
|
||||||
|
|
||||||
|
private static final String EMAIL_TEMPLATE =
|
||||||
|
"""
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Order Confirmation</title>
|
||||||
|
<style>
|
||||||
|
body { margin:0; padding:0; background:#F3F3F3; }
|
||||||
|
table { border-collapse:collapse; }
|
||||||
|
img { border:0; line-height:100%; outline:none; text-decoration:none; }
|
||||||
|
.container { width:100%; }
|
||||||
|
.wrapper { max-width:600px; width:100%; margin:0 auto; }
|
||||||
|
.font { font-family:-apple-system, Arial, Helvetica, sans-serif; color:#000000; }
|
||||||
|
.headline { font-size:28px; line-height:36px; font-weight:800; text-align:center; }
|
||||||
|
@media only screen and (max-width:600px) {
|
||||||
|
.wrapper { max-width:100% !important; }
|
||||||
|
.headline { font-size:22px !important; line-height:30px !important; }
|
||||||
|
.mobile-pad { padding-left:16px !important; padding-right:16px !important; }
|
||||||
|
.two-col-left, .two-col-right { display:block !important; width:100% !important; text-align:center !important; padding:12px 16px !important; }
|
||||||
|
.two-col-right img { width:160px !important; height:auto !important; }
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body class="font">
|
||||||
|
<div style="display:none; max-height:0; overflow:hidden; opacity:0;">Your photos are waiting to be printed</div>
|
||||||
|
<table role="presentation" class="container" width="100%" cellpadding="0" cellspacing="0" style="background:#F3F3F3;">
|
||||||
|
<tr>
|
||||||
|
<td align="center" style="padding:24px 12px;">
|
||||||
|
<table role="presentation" class="wrapper" cellpadding="0" cellspacing="0" style="background:#FFFFFF; border-radius:12px;">
|
||||||
|
<tr>
|
||||||
|
<td align="center" style="padding:24px 24px 8px 24px;">
|
||||||
|
<img src="https://image.tttzai.com/memory-block/upload/20251119/9b26919610e76dd31499af85c1a2686f.jpg" alt="Memory Block" width="160" style="width:160px; height:auto; display:block;">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center" style="padding:0 16px 16px 16px;">
|
||||||
|
<img src="https://image.tttzai.com/memory-block/upload/20251119/499b27b308b08cc691370d4b772d334c.jpg" width="552" style="width:100%; max-width:552px; height:auto; border-radius:16px; box-shadow:0 4px 12px rgba(0,0,0,0.08); display:block;" alt="Preparing photo prints">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center" style="padding:8px 24px;">
|
||||||
|
<div class="headline" style="font-size:28px; line-height:36px; font-weight:800; text-align:center;">Your photos are waiting<br>to be printed...</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center" style="padding:4px 24px 0 24px;">
|
||||||
|
<div style="font-size:14px; line-height:22px; color:#666666; text-align:center;">Thank you for creating your order!<br>Your order number is:</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center" style="padding:6px 24px;">
|
||||||
|
<div style="font-size:18px; font-weight:800; color:#E53935;">Order: {ORDER_NUMBER}</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center" style="padding:4px 24px 0 24px;">
|
||||||
|
<div style="font-size:14px; line-height:22px; color:#666666; text-align:center;">Please share this number with our team at the counter so we can complete your payment and start bringing your memories to life.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center" style="padding:8px 24px;">
|
||||||
|
<div style="font-size:14px; line-height:22px; color:#666666; text-align:center;">We’ll begin printing as soon as payment is confirmed.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center" style="padding:16px 24px 8px;">
|
||||||
|
<div style="font-size:14px; line-height:22px; color:#666666; text-align:center;">Thank you,<br>Team Memory Block</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="padding:16px 0 0 0;">
|
||||||
|
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background:#FFF4F4;">
|
||||||
|
<tr>
|
||||||
|
<td valign="top" class="two-col-left" style="padding:20px 24px;">
|
||||||
|
<div style="font-size:20px; font-weight:800;">Make memories <span style="color:#E53935;">last forever.</span></div>
|
||||||
|
<table role="presentation" cellpadding="0" cellspacing="0" style="margin-top:8px;">
|
||||||
|
<tr>
|
||||||
|
<td valign="top" style="color:#E53935; font-size:18px; padding-right:8px;">✓</td>
|
||||||
|
<td style="font-size:14px; line-height:22px;">Satisfaction guaranteed</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td valign="top" style="color:#E53935; font-size:18px; padding-right:8px;">✓</td>
|
||||||
|
<td style="font-size:14px; line-height:22px;">Made to last a lifetime</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td valign="top" style="color:#E53935; font-size:18px; padding-right:8px;">✓</td>
|
||||||
|
<td style="font-size:14px; line-height:22px;">Quick and easy</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
<td valign="middle" align="right" class="two-col-right" style="padding:20px 24px;">
|
||||||
|
<img src="https://image.tttzai.com/memory-block/upload/20251119/dc6d53427ee873e517864f4025af75bf.jpg" width="140" style="width:140px; height:auto; border-radius:8px; display:block;" alt="Sample">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center" style="padding:16px 24px 0 24px;">
|
||||||
|
<div style="font-size:20px; font-weight:800;">We’re here to help</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center" style="padding:8px 24px 4px 24px;">
|
||||||
|
<div style="font-size:14px; line-height:22px; color:#666666; text-align:center;">Your order is now in our system and will be printed once payment is completed.<br>If you need any help in the meantime, just speak with our kiosk team or reach out using the details below.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="padding:12px 24px 24px 24px;">
|
||||||
|
<table role="presentation" width="100%" cellpadding="0" cellspacing="0">
|
||||||
|
<tr>
|
||||||
|
<td style="border-top:1px solid #EEEEEE; padding-top:14px;">
|
||||||
|
<table role="presentation" align="center" cellpadding="0" cellspacing="0">
|
||||||
|
<tr>
|
||||||
|
<td style="font-size:14px; line-height:22px; color:#000000; padding:0 8px;">
|
||||||
|
<a href="https://memoryblock.com.au" style="color:#000000; text-decoration:none;">memory_block_au</a>
|
||||||
|
</td>
|
||||||
|
<td style="font-size:14px; line-height:22px; color:#999999;">•</td>
|
||||||
|
<td style="font-size:14px; line-height:22px; color:#000000; padding:0 8px;">
|
||||||
|
<a href="mailto:info@memoryblock.com.au" style="color:#000000; text-decoration:none;">info@memoryblock.com.au</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
""";
|
||||||
|
|
||||||
|
public void sendHtmlEmail(String to, String orderSN) throws MessagingException {
|
||||||
|
String htmlContent = EMAIL_TEMPLATE.replace("{ORDER_NUMBER}", orderSN);
|
||||||
|
MimeMessage message = mailSender.createMimeMessage();
|
||||||
|
MimeMessageHelper helper = new MimeMessageHelper(message, true, "UTF-8");
|
||||||
|
helper.setTo(to);
|
||||||
|
helper.setSubject("Order Confirmation - #" + orderSN);
|
||||||
|
helper.setText(htmlContent, true); // HTML = true
|
||||||
|
helper.setFrom(FROM_EMAIL); // 必须与 Gmail 账号一致
|
||||||
|
|
||||||
|
mailSender.send(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -47,6 +47,20 @@ spring:
|
|||||||
exclusions: '*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*'
|
exclusions: '*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*'
|
||||||
session-stat-enable: true
|
session-stat-enable: true
|
||||||
session-stat-max-count: 10
|
session-stat-max-count: 10
|
||||||
|
mail:
|
||||||
|
host: smtp.gmail.com
|
||||||
|
port: 587
|
||||||
|
username: your-email@gmail.com # 你的 Gmail 地址
|
||||||
|
password: abcdefghijklmnop # 16位应用专用密码(无空格)
|
||||||
|
properties:
|
||||||
|
mail:
|
||||||
|
smtp:
|
||||||
|
auth: true
|
||||||
|
starttls:
|
||||||
|
enable: true
|
||||||
|
required: true
|
||||||
|
ssl:
|
||||||
|
protocols: TLSv1.2 TLSv1.3
|
||||||
|
|
||||||
# mybatis
|
# mybatis
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
|
|||||||
Reference in New Issue
Block a user