Compare commits

...
2 Commits
Author SHA1 Message Date
wonder 594eb23979 ✨Feat: 增加发送邮件功能 2025-10-07 22:50:59 +08:00
wonder 12b21004b3 🔧Chore: 修正任务 2025-10-07 22:17:56 +08:00
7 changed files with 171 additions and 10 deletions
+9 -10
View File
@@ -7,13 +7,12 @@
| ✅T01 | 搭建 Vue 3 前端项目(使用 Vite) |
| ✅T02 | 开发邮件发送页面(含表单和附件上传功能) |
| ✅T03 | 集成 Axios 实现 AJAX 提交邮件数据 |
| T04 | 实现邮件发送状态提示(成功/失败) |
| T05 | 创建 Spring Boot 后端项目,集成 Spring Mail 发送邮件功能 |
| T06 | 开发 `/api/email/send` 接口,支持附件上传 |
| T07 | 配置 SMTP 参数(YAML/Properties) |
| T08 | 实现接口安全控制(API Key 或 JWT) |
| T09 | 处理附件上传逻辑(格式校验、大小限制、命名规则) |
| T10 | 邮件发送错误处理与格式验证(邮箱、SMTP 配置等) |
| T11 | 配置部署前端(Nginx / Vercel) |
| T12 | 部署后端服务(JAR/WAR 或 Docker) |
| T14 | 进行性能测试 |
| T04 | 创建 Spring Boot 后端项目,集成 Spring Mail 发送邮件功能 |
| T05 | 开发 `/api/email/send` 接口,支持附件上传 |
| T06 | 配置 SMTP 参数(YAML/Properties) |
| T07 | 实现接口安全控制(API Key 或 JWT) |
| T08 | 处理附件上传逻辑(格式校验、大小限制、命名规则) |
| T09 | 邮件发送错误处理与格式验证(邮箱、SMTP 配置等) |
| T10 | 配置部署前端(Nginx / Vercel) |
| T11 | 部署后端服务(JAR/WAR 或 Docker) |
| T12 | 进行性能测试 |
+38
View File
@@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store
+40
View File
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cn.hezhaohui</groupId>
<artifactId>backend</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.1</version>
</parent>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,14 @@
package cn.hezhaohui.mail;
import cn.hezhaohui.mail.service.MailService;
import jakarta.annotation.Resource;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SendMailApplication {
public static void main(String[] args) {
SpringApplication.run(SendMailApplication.class, args);
}
}
@@ -0,0 +1,31 @@
package cn.hezhaohui.mail.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import java.util.Properties;
@Configuration
public class MailConfig {
@Bean
public JavaMailSender getJavaMailSender() {
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost("smtp.163.com");
mailSender.setPort(465);
mailSender.setUsername("hezhaohui0807@163.com");
mailSender.setPassword("AMaauzQZQMnkSfZi");
Properties properties = mailSender.getJavaMailProperties();
properties.put("mail.transport.protocol", "smtp");
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.ssl.enable", "true");
properties.put("mail.smtp.starttls.enable", "true");
properties.put("mail.debug", "true");
return mailSender;
}
}
@@ -0,0 +1,22 @@
package cn.hezhaohui.mail.service;
import jakarta.annotation.Resource;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;
@Service
public class MailService {
@Resource
private JavaMailSender emailSender;
public void sendMessage(String to, String subject, String text) {
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom("hezhaohui0807@163.com");
message.setTo(to);
message.setSubject(subject);
message.setText(text);
emailSender.send(message);
}
}
@@ -0,0 +1,17 @@
package cn.hezhaohui.mail.service;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class MailServiceTest {
@Resource
private MailService mailService;
@Test
void sendMessage() {
mailService.sendMessage("2311719626@qq.com", "你好", "Test");
}
}