I'm sending emails from java code.My configuration is
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "****");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "587");
On my other question EJP answered
Any protocol that uses STARTTLS is in SSL mode after the STARTTLS command is issued
But my debug output shows:DEBUG SMTP: trying to connect to host "****", port 587, isSSL false.
So my question sounds like
Is such configuration really safe and uses SSL
as EJP said despite of isSSL=false on my debug output?
UPDATE
connecting code
Transport transport = session.getTransport("smtp");
transport.connect("host", 587,"username", "password");
when I wrote Transport transport = session.getTransport("smtps")
I got
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection
StartTLS is a protocol command used to inform the email server that the email client wants to upgrade from an insecure connection to a secure one using TLS or SSL. StartTLS is used with SMTP and IMAP, while POP3 uses the slightly different command for encryption, STLS.
To enable SMTP connections over SSL, set the "mail. smtp. ssl. enable" property to "true".
Send Mail in Java using SMTP without authentication We need to set the mail. smtp. host property with the SMTP server host. If the SMTP server is not running on default port (25), then you will also need to set mail.
Set mail.smtp.starttls.required=true
This ensures TLS is used or connection won't happen
REF: https://javamail.java.net/nonav/docs/api/com/sun/mail/smtp/package-summary.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With