Код: Выделить всё
jakarta.mail.Provider: com.sun.mail.imap.IMAPProvider not a subtype
Код: Выделить всё
@Service
@EnableAutoConfiguration
public class EmailService {
@Autowired
private MailSender mailSender;
public void sendEmail(String to, String subject, String text) {
try{
SimpleMailMessage message = new SimpleMailMessage();
message.setTo(to);
message.setSubject(subject);
message.setText(text);
mailSender.send(message);
} catch(Exception e){
System.out.println(e.getMessage());
}
}
Код: Выделить всё
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=mygmailaccount
spring.mail.password=password
spring.mail.properties.mail.smtp.auth = true
spring.mail.properties.mail.smtp.starttls.enable = true
# Other properties
spring.mail.properties.mail.smtp.connectiontimeout=5000
spring.mail.properties.mail.smtp.timeout=5000
spring.mail.properties.mail.smtp.writetimeout=5000
Код: Выделить всё
implementation 'org.springframework.boot:spring-boot-starter-mail'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
//implementation group: 'com.sun.mail', name: 'javax.mail', version: '1.6.2'
implementation group: 'com.sun.mail', name: 'jakarta.mail', version: '1.6.7'
Подробнее здесь: https://stackoverflow.com/questions/775 ... -a-subtype