Note
pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
application.yml
spring:
mail:
host: smtp.●●.●●(For gmail, "smtp".gmail.com」)
port: 587
username: (mail address)
password: (password)
properties.mail.smtp.auth: true
properties.mail.smtp.starttls.enable: true
sample
@Autowired
private MailSender sender;
public void sendMail() {
SimpleMailMessage msg = new SimpleMailMessage();
msg.setFrom("Sender email address");
msg.setTo("Destination email address");
msg.setSubject("Subject input field");
msg.setText("Body input field");
this.sender.send(msg);
}
Write sample in the class.
Recommended Posts