commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: [EMAIL] Using Apache Commons Email and Google
Date Mon, 16 Nov 2009 15:45:48 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Stephano,

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 "smtp.gmail.com", port 465, isSSL false

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

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.

> http://www.rgagnon.com/javadetails/java-0570.html

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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksBc6wACgkQ9CaO5/Lv0PCC9gCdEyCUKnv8znCnuL3hvLcv/Bp+
CzoAoJA2vp9VPQHzATxRgD3SUe3J86tW
=mQy/
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message