For IntelliJ IDEA and
Android Studio


/** * Removes a ProtocolCommandListener. * * Delegates this incorrectly named method - removeProtocolCommandistener (note the missing "L")- to * the correct method {@link SocketClient#removeProtocolCommandListener} * @param listener The ProtocolCommandListener to remove */ public void removeProtocolCommandistener(org.apache.commons.net.ProtocolCommandListener listener){ removeProtocolCommandListener(listener); }
/** * * @param command the command to send (as an int defined in {@link SMPTCommand}) * @param args the command arguments, may be {@code null} * @param includeSpace if {@code true}, add a space between the command and its arguments * @return the reply code * @throws IOException */ private int __sendCommand(int command, String args, boolean includeSpace) throws IOException { return __sendCommand(SMTPCommand.getCommand(command), args, includeSpace); }
@Override public void close() throws IOException { smtpClient.disconnect(); } }
public SMTPMessageSender connect(String ip, int port) throws IOException { smtpClient.connect(ip, port); return this; }
protected SMTPClient createClient() { return new SMTPClient(); }
@Test public void testToStringNoSubject() { SimpleSMTPHeader hdr = new SimpleSMTPHeader("from@here.invalid", "to@there.invalid", null); assertNotNull(hdr); // Note that the DotTerminatedMessageWriter converts LF to CRLF assertEquals("From: from@here.invalid\nTo: to@there.invalid\n\n", checkDate(hdr.toString())); }
public void enableSSL(final boolean verify) { _socketFactory_ = sslFactory(verify); }
/** * The TLS command execution. * @throws IOException If an I/O error occurs while sending * the command or performing the negotiation. * @return TRUE if the command and negotiation succeeded. */ public boolean execTLS() throws IOException { if (!SMTPReply.isPositiveCompletion(sendCommand("STARTTLS"))) { return false; //throw new SSLException(getReplyString()); } performSSLNegotiation(); return true; }
/*** * Logout of the SMTP server by sending the QUIT command. * <p> * @return True if successfully completed, false if not. * @throws SMTPConnectionClosedException * If the SMTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send SMTP reply code 421. This exception may be caught either * as an IOException or independently as itself. * @throws IOException If an I/O error occurs while either sending a * command to the server or receiving a reply from the server. ***/ public boolean logout() throws IOException { return SMTPReply.isPositiveCompletion(quit()); }
private boolean authPlain(String smtpUser, String smtpPass) throws UnsupportedEncodingException, IOException { String token = '\0' + smtpUser + '\0' + smtpPass; String cmd = "PLAIN " + encodeBase64(token.getBytes(UTF_8)); return SMTPReply.isPositiveCompletion(sendCommand("AUTH", cmd)); }
@Test public void testToStringAddHeader() { SimpleSMTPHeader hdr = new SimpleSMTPHeader("from@here.invalid", null, null); assertNotNull(hdr); hdr.addHeaderField("X-Header1", "value 1"); hdr.addHeaderField("X-Header2", "value 2"); // Note that the DotTerminatedMessageWriter converts LF to CRLF assertEquals("X-Header1: value 1\nX-Header2: value 2\nFrom: from@here.invalid\n\n", checkDate(hdr.toString())); }
/*** * Sends a NOOP command to the SMTP server. This is useful for preventing * server timeouts. * <p> * @return True if successfully completed, false if not. * @throws SMTPConnectionClosedException * If the SMTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send SMTP reply code 421. This exception may be caught either * as an IOException or independently as itself. * @throws IOException If an I/O error occurs while either sending a * command to the server or receiving a reply from the server. ***/ public boolean sendNoOp() throws IOException { return SMTPReply.isPositiveCompletion(noop()); }
/*** * Aborts the current mail transaction, resetting all server stored * sender, recipient, and mail data, cleaing all buffers and tables. * <p> * @return True if successfully completed, false if not. * @throws SMTPConnectionClosedException * If the SMTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send SMTP reply code 421. This exception may be caught either * as an IOException or independently as itself. * @throws IOException If an I/O error occurs while either sending a * command to the server or receiving a reply from the server. ***/ public boolean reset() throws IOException { return SMTPReply.isPositiveCompletion(rset()); }
@Test public void testToStringNoTo() { SimpleSMTPHeader hdr = new SimpleSMTPHeader("from@here.invalid", null, null); assertNotNull(hdr); // Note that the DotTerminatedMessageWriter converts LF to CRLF assertEquals("From: from@here.invalid\n\n", checkDate(hdr.toString())); }