commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: [EMAIL] Using Apache Commons Email and Google
Date Mon, 16 Nov 2009 15:45:48 GMT
Hash: SHA1


On 11/16/2009 9:43 AM, Stefano "Kismet" Lenzi wrote:
> I was trying to use the Commons Email project for sending email with
> the Google provider, but I failed. I tried with the following code
> 		SimpleEmail email = new SimpleEmail();
> 		email.setDebug(true);
> 		email.addTo(MAIL_DESTINATION, "Stefano Lenzi");
> 		email.setFrom(MAIL_SENDER, "Test");
> 		email.setSubject("Test message");
> 		email.setMsg("This is a simple test of commons-email");
> 		email.setHostName(SMTP_HOST_NAME);
> 		email.setAuthentication(SMTP_AUTH_USER, SMTP_AUTH_PWD);
> 		email.setTLS(true);
> 		email.setSmtpPort(SMTP_HOST_PORT);
> 		email.send();
> but nothing happened.

Try setting -Dmail.debug=true and run it again. This will give you much
more output from Javamail.

It's unclear from the javadoc, but it's possible that setTLS(true)
merely configures Javamail to use STARTTLS over a plaintext SMTP
connection. If you want to use SMTPS, try setting
- -Dmail.transport.protocol=smtps to see if that helps.

> DEBUG SMTP: trying to connect to host "", port 465, isSSL false

See that SSL=false. If you want SSL, use setSSL(true) instead of

I'm not sure what gmail prefers and/or requires, but generally
STARTTLS-over-SMTP will give you better performance, because only the
authentication is encrypted and not the entire SMTP conversation.


That page indicates that GMail requires SSL, not TLS. Try changing
setTLS(true) to setSSL(true) and see if that works.

Hope that helps,
- -chris
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message