79498389

Date: 2025-03-10 15:06:45
Score: 1
Natty:
Report link

Looking at your error "Could not convert socket to TLS", you're having a TLS negotiation issue with your SMTP server. Here's how to fix it:

Try a different port with proper TLS settings:

prop.put("mail.smtp.port", "587"); // for STARTTLS

Or just copy/paste this:

@PostConstruct
public void initProperties() {
    prop.put("mail.smtp.auth", "true");
    prop.put("mail.smtp.starttls.enable", "true");
    prop.put("mail.smtp.host", "live.smtp.mailtrap.io");
    prop.put("mail.smtp.port", "587");
}

// In your Authenticator:
return new PasswordAuthentication("username", "password");

Disclaimer: I've crafted the answer based on this tutorial.

Reasons:
  • Blacklisted phrase (1): this tutorial
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: ap ye