Dear All,
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. Here is the debug shown 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
I believe that the problem is that the protocol chosen is "smtp" while
it should be "smpts". In fact, I have later tryed the code available
here:
http://www.rgagnon.com/javadetails/java-0570.html
the it worked perfectly, and the two difference are the protocol
chosen for sending the email and the way the transport is initialized.
Is it a bug in Commons Email, or am I doing something wrong?
Ciao,
Stefano Lenzi
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]