commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefano \"Kismet\" Lenzi" <>
Subject Re: [EMAIL] Using Apache Commons Email and Google
Date Mon, 16 Nov 2009 18:27:09 GMT
On Mon, Nov 16, 2009 at 16:45, Christopher Schultz
<> wrote:
> 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.

I have tried to set the option but the output didn't change

> 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.

Even the -Dmail.transport.protocol=smtps  system property didn't
change anything, it looks like that the system properties are not used
by Commons Email

>> DEBUG SMTP: trying to connect to host "", port 465, isSSL false
> See that SSL=false. If you want SSL, use setSSL(true) instead of
> setTLS(true).

I don't know why I haven't tried it before, but I'm glad to say that
it worked :)
It's strange that the first lines of the output didn't change

DEBUG: JavaMail version 1.4.1ea-SNAPSHOT
DEBUG: not loading file: C:\Programmi\Java\jre6\lib\javamail.providers
C:\Programmi\Java\jre6\lib\javamail.providers (Impossibile trovare il
file specificato)
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.providers
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name:
Microsystems, Inc],
Microsystems, Inc],
Microsystems, Inc],
Microsystems, Inc],
Microsystems, Inc],
Microsystems, Inc]}
DEBUG: Providers Listed By Protocol:
Microsystems, Inc],
Microsystems, Inc],
Microsystems, Inc],
Microsystems, Inc],
Microsystems, Inc],
Microsystems, Inc]}
DEBUG: successfully loaded resource: /META-INF/
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/
DEBUG: not loading file: C:\Programmi\Java\jre6\lib\
C:\Programmi\Java\jre6\lib\ (Impossibile trovare
il file specificato)
DEBUG: getProvider() returning
Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "", port 465, isSSL false
220 ESMTP 3sm5919994fge.24
DEBUG SMTP: connected to host "", port: 465

In particular, the lines:
"DEBUG: getProvider() returning
Microsystems, Inc]"
"DEBUG SMTP: trying to connect to host "", port 465, isSSL false"

> 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

Thank you it helped!

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

View raw message