private Socket getOutGoingSocket() throws IOException { Socket s; if (info.isUseSSL()) { SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault(); s = sslsocketfactory.createSocket(info.getOutgoingServerName(), info.getOutgoingPort()); } else { s = new Socket(info.getOutgoingServerName(), info.getOutgoingPort()); } return s; }
public boolean sendMessage(Letter l) throws IOException, ProtocolException { boolean result = false; Socket s = this.getOutGoingSocket(); PostProtocol protocol = this.getOutGoingProtocol(s); protocol.startSession(info.getOutgoingServerName()); protocol.authorization(info.getUsername(), info.getPassword()); result = protocol.sendMessage(l); protocol.closeSession(); s.close(); return result; }