aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes Gmail and port 465 vs. port 587 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Gmail and port 465 vs. port 587" Watch "Gmail and port 465 vs. port 587" New topic
Author

Gmail and port 465 vs. port 587

Kerry Shetline
Greenhorn

Joined: Feb 09, 2006
Posts: 14
I've been testing some code for sending secure e-mail, and I've been using my Gmail account for testing. I've done a lot of googling on the subject of Java and secure SMTP access, and found a lot of specific example regarding Gmail in particular.

I've got code that works now, but I'm a bit puzzled. In order to make my code work, I MUST use port 465. I cannot get the code to work if I try to access Gmail using port 587, even though that's the recommended port and the one that I've always used to configure an e-mail client like Mac OS X Mail or Mozilla.

In the googling I've done, I've seen stories of success and failure, and I've seen examples with both ports used. The successful code seems to be using port 465, but I've never heard the particular port used mentioned as an important ingredient for success. In fact, to the minimal degree I've heard the port discussed at all, it's been to say "use either one, it doesn't matter."

This leaves me feeling that there's something missing in my code -- I'd think that if everything were in order, port 587 would also work for me. Further, while port 465 does work, in the debug trace I see "isSSL false", even though I'm specifying an SSL socket factory and am pretty sure that SSL is being used.

Here's a portion of the debug log where I fail using port 587:



What's all this about a "plaintext connection"? Why does it say, both here and below when my connection succeeded "isSSL false"? I experimented with the SMTPSSLTransport class, which gave me the more comforting "isSSL true", but my results didn't change one bit.

Here's a portion of the debug log where I succeed using port 465:



And for any light it might shed on the situation, here's an edited-down version of my code:

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Gmail and port 465 vs. port 587