commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Siegfried Goeschl <siegfried.goes...@it20one.at>
Subject Re: [EMAIL] Using Apache Commons Email and Google
Date Mon, 16 Nov 2009 21:18:50 GMT
Hi folks,

see my comments below ...

Cheers,

Siegfried Goeschl

Stefano "Kismet" Lenzi wrote:
> On Mon, Nov 16, 2009 at 16:45, Christopher Schultz
> <chris@christopherschultz.net> wrote:
>   
>> -----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.
>>     
>
> I have tried to set the option but the output didn't change
>
>   
[SG] you already enabled the debug mode using email.setDebug()
>> 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
>   
[SG] correct - all the required properties are set within commons-email
thereby not relying on system properties.
>   
>>> 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 :)
> It's strange that the first lines of the output didn't change
>   
[SG] Should provide some Q&A covering connectivity to GMAIL
> DEBUG: JavaMail version 1.4.1ea-SNAPSHOT
> DEBUG: not loading file: C:\Programmi\Java\jre6\lib\javamail.providers
> DEBUG: java.io.FileNotFoundException:
> 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:
> {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun
> Microsystems, Inc],
> com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun
> Microsystems, Inc],
> com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun
> Microsystems, Inc],
> com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun
> Microsystems, Inc],
> com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun
> Microsystems, Inc],
> com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun
> Microsystems, Inc]}
> DEBUG: Providers Listed By Protocol:
> {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun
> Microsystems, Inc],
> imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun
> Microsystems, Inc],
> smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun
> Microsystems, Inc],
> pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun
> Microsystems, Inc],
> pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun
> Microsystems, Inc],
> smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun
> Microsystems, Inc]}
> DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
> DEBUG: !anyLoaded
> DEBUG: not loading resource: /META-INF/javamail.address.map
> DEBUG: not loading file: C:\Programmi\Java\jre6\lib\javamail.address.map
> DEBUG: java.io.FileNotFoundException:
> C:\Programmi\Java\jre6\lib\javamail.address.map (Impossibile trovare
> il file specificato)
> DEBUG: getProvider() returning
> javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun
> Microsystems, Inc]
> DEBUG SMTP: useEhlo true, useAuth true
> DEBUG SMTP: useEhlo true, useAuth true
> DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 465, isSSL false
> 220 mx.google.com ESMTP 3sm5919994fge.24
> DEBUG SMTP: connected to host "smtp.gmail.com", port: 465
>
> In particular, the lines:
> "DEBUG: getProvider() returning
> javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun
> Microsystems, Inc]"
> "DEBUG SMTP: trying to connect to host "smtp.gmail.com", 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.
>>
>>     
>>> 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.
>>     
[SG] thanks for the link
>> Hope that helps,
>> - -chris
>>     
>
> Thank you it helped!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>
>
>   

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


Mime
View raw message