From: Nigel Wade on
On Tue, 08 Jun 2010 15:58:56 -0700, jesbox wrote:

> Thanks for the tips. I have changed into hard-coded values, i.e.
> System.setProperty("mail.smtps.auth", "true"); // enable https new
> Mailer("smtp.gmail.com", 465, "myEmail(a)gmail.com",
> "a_password").sendMail(email);
>
> The exception I get is:
> org.codemonkey.vesijama.MailException: Generic error: Could not connect
> to SMTP host: smtp.gmail.com, port: 465, response: -1
> at org.codemonkey.vesijama.Mailer.sendMail(Mailer.java:180) at
> TestMail.sendMail(TestMail.java:57) at
> TestMail.testMail(TestMail.java:52) at TestMail.main(TestMail.java:33)
> Caused by: javax.mail.MessagingException: Could not connect to SMTP
> host: smtp.gmail.com, port: 465, response: -1
> at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:
> 1533)
> at
> com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java: 453)
> at javax.mail.Service.connect(Service.java:313) at
> javax.mail.Service.connect(Service.java:172)


Do you know that smtps works with the vesijama Mailer class?

In my limited understanding of JavaMail I believe that to use smtps
requires the use of a different Transport. The contents of the Mailer
class is a black box. If it doesn't select the correct Transport for the
smtps protocol then the connection will definitely fail in the SSL
handshake.

I would use the bare JavaMail interface rather than some unknown wrapper
class. At least you can then see exactly what's going on. If you google
"gmail javamail" you should get some useful info. Very high up on the
list of results is the JavaMail FAQ, and that has pointers to example
code, and includes an example of smtps mail submission to Gmail.

--
Nigel Wade