@ The answer was helpful (and I voted for it), but I had to tweak it a bit to make it work for me:
SSLSocket sslSocket = (SSLSocket) ((SSLSocketFactory) SSLSocketFactory.getDefault()).createSocket( socket, socket.getInetAddress().getHostAddress(), socket.getPort(), true); InputStream inputStream = sslSocket.getInputStream(); OutputStream outputStream = sslSocket.getOutputStream(); // reads from the socket Scanner scanner = new Scanner(inputStream); // writes to the socket OutputStream outputStream = new BufferedOutputStream(outputStream);
Tested with Java 7 and GMail (smtp.gmail.com) on port 587.
james.garriss
source share