很久没写JAVA程序了,原来用GMAIL发送邮件这么简单

写完代码,配置了GMAIL,死活发布出去,碰到了错误535-5.7.8 Username and Password not accepted.

首先先写代码,然后配置GMAIL.

第一写代码:

当你需要在 Spring Boot 中实现邮件通知时,你可以使用 Spring 的 JavaMailSender 来发送电子邮件。首先,确保你的 Spring Boot 项目已经配置好了邮件发送功能。下面是一个示例代码,演示如何在 Spring Boot 中发送邮件通知:

首先,在 `application.properties` 或 `application.yml` 文件中配置邮件服务的信息,例如:

```properties
# SMTP邮件发送配置
spring.mail.host=your-smtp-server.com
spring.mail.port=587
[email protected]
spring.mail.password=your-email-password
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
```

YML属性文件

spring:
  mail:
    host: your-smtp-server.com
    port: 587
    use

你可能感兴趣的:(JAVA,java)