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 21:26:42 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Stefano,

On 11/16/2009 1:27 PM, Stefano "Kismet" Lenzi wrote:
> On Mon, Nov 16, 2009 at 16:45, Christopher Schultz
> <chris@christopherschultz.net> wrote:
>>
>> 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

Hmm... that's strange. I thought javamail would read system properties
as well as those set directly using a java.util.Properties object, but
maybe it doesn't. Commons-email doesn't appear to give you the option of
setting javamail properties directly, but it does allow you to set the
javamail session like this:

Properties props = new Properties();
props.put("mail.transport.protocol", "smtps");
...

Session session = Session.getDefaultInstance(props);

...
email.setMailSession(session);
email.send();

This should allow you to set properties such as mail.debug,
mail.transport.protocol, etc.

>>> 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 don't know why I haven't tried it before, but I'm glad to say that
> it worked :)

Glad to help.

> In particular, the lines:
> "DEBUG: getProvider() returning
> javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun
> Microsystems, Inc]"

I don't find anything strange about the above log message, do you?

> "DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 465, isSSL false"

Now /that/ is strange if you have set SSL=true. Perhaps there's a bug in
the debug logging.

I have found that commons-email acts strangely in a number of
circumstances. I unfortunately had to abandon its use a while back in
order to be able to send attachments along with text *and* HTML email
messages. I wrote my own wrapper with what I believe is a simpler API.
You are welcome to it: http://www.christopherschultz.net/projects/java/

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksBw5IACgkQ9CaO5/Lv0PAkTgCffhkbKXQCSp1y5UB4XfOnBi5x
NRgAoJQtnIbh60dVUlXIh78tux/mY2+6
=4S7Y
-----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