Wave Wave -4 years ago 133
Java Question

using java mail api

I am using Java mail api to send a mail using

smtp.gmail.com
as host. When I use the below code and enable tls it works fine but if I disable it, its throwing
Must issue a STARTTLS command first
error.

mailProperties.put("mail.smtp.starttls.enable", "true");


What does it mean ? So to connect to gmail I should set this flag always ? And also to connect to any mail server should we always enable secure connection (tls or ssl) ?

Answer Source

The GMail smtp server seems to require TLS authentication. (See here). Which means that the server will reject your query if you do not enable TLS.

So yes, to connect to GMail you need to enable TLS. For a general mail server there usually is no need.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download