-3
Ich habe ein Formular mit From/Tp Eingabefeld und TextArea als Box. Ich möchte E-Mail mit Spring Boot senden. Wie kann ich E-Mail mit Spring Boot senden?Email mit Spring Boot senden
Danke für Antworten.
Ich habe ein Formular mit From/Tp Eingabefeld und TextArea als Box. Ich möchte E-Mail mit Spring Boot senden. Wie kann ich E-Mail mit Spring Boot senden?Email mit Spring Boot senden
Danke für Antworten.
es funktioniert jetzt
Das ist mein Controller ist
@Controller
@RequestMapping("/sendmail")
public class MailController {
@Autowired
private MailService mailService;
@RequestMapping(method = RequestMethod.POST)
private String sendMail(HttpServletRequest request) {
String covere = request.getParameter("covere");
try {
mailService.sendMail(covere);
return "apply";
} catch (MailException e) {
e.printStackTrace();
}
return "apply";
}
}
Das ist mein Dienst ist
@Component
public class MailService {
@Autowired
private JavaMailSender javaMailSender;
public void sendMail(String covere) throws MailException{
SimpleMailMessage mail = new SimpleMailMessage();
mail.setTo("[email protected]");
mail.setFrom("[email protected]");
mail.setSubject("Test");
mail.setText(covere);
javaMailSender.send(mail);
}
}
Das ist mein Eigentum Dateien ist
spring.mail.host = smtp.gmail.com
spring.mail.port= 465
spring.mail.username = [email protected]
spring.mail.password = losangeles4004*
send.from.email= [email protected]
spring.mail.properties.mail.smtp.auth = true;
spring.mail.properties.mail.smtp.starttls.enable = true
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.properties.mail.smtp.ssl.enable = true
spring.mail.properties.mail.socketFactory.port=587
spring.mail.properties.mail.socketFactory.class=javax.net.ssl.SSLSocketFactory
spring.mail.properties.mail.socketFactory.fallback=false
Dank Advance nicht Hilfe Bruder. Zeigen Sie Ihren Code, den Sie ausprobiert haben, und wir können bei Fehlern helfen –
Haben Sie dies überprüft: https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-email.html? –