private void writeLine(String s, boolean sensitive) throws IOException { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_SMTP) { final String commandToLog; if (sensitive && !K9MailLib.isDebugSensitive()) { commandToLog = "SMTP >>> *sensitive*"; } else { commandToLog = "SMTP >>> " + s; } Timber.d(commandToLog); } byte[] data = s.concat("\r\n").getBytes(); /* * Important: Send command + CRLF using just one write() call. Using * multiple calls will likely result in multiple TCP packets and some * SMTP servers misbehave if CR and LF arrive in separate pakets. * See issue 799. */ outputStream.write(data); outputStream.flush(); }
public String sendSaslIrCommand(String command, String initialClientResponse, boolean sensitive) throws IOException, MessagingException { try { open(); String tag = Integer.toString(nextCommandTag++); String commandToSend = tag + " " + command + " " + initialClientResponse + "\r\n"; outputStream.write(commandToSend.getBytes()); outputStream.flush(); if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) { if (sensitive && !K9MailLib.isDebugSensitive()) { Timber.v("%s>>> [Command Hidden, Enable Sensitive Debug Logging To Show]", getLogId()); } else { Timber.v("%s>>> %s %s %s", getLogId(), tag, command, initialClientResponse); } } return tag; } catch (IOException | MessagingException e) { close(); throw e; } }
public String sendCommand(String command, boolean sensitive) throws MessagingException, IOException { try { open(); String tag = Integer.toString(nextCommandTag++); String commandToSend = tag + " " + command + "\r\n"; outputStream.write(commandToSend.getBytes()); outputStream.flush(); if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) { if (sensitive && !K9MailLib.isDebugSensitive()) { Timber.v("%s>>> [Command Hidden, Enable Sensitive Debug Logging To Show]", getLogId()); } else { Timber.v("%s>>> %s %s", getLogId(), tag, command); } } return tag; } catch (IOException | MessagingException e) { close(); throw e; } }
public List<ImapResponse> executeSimpleCommand(String command, boolean sensitive) throws IOException, MessagingException { String commandToLog = command; if (sensitive && !K9MailLib.isDebugSensitive()) { commandToLog = "*sensitive*"; } String tag = sendCommand(command, sensitive); try { return responseParser.readStatusResponse(tag, commandToLog, getLogId(), null); } catch (IOException e) { close(); throw e; } }
private String executeSimpleCommand(String command, boolean sensitive) throws MessagingException { try { if (command != null) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) { if (sensitive && !K9MailLib.isDebugSensitive()) { Timber.d(">>> [Command Hidden, Enable Sensitive Debug Logging To Show]"); } else { Timber.d(">>> %s", command); } } writeLine(command); } String response = readLine(); if (response.length() == 0 || response.charAt(0) != '+') { throw new Pop3ErrorResponse(response); } return response; } catch (MessagingException me) { throw me; } catch (Exception e) { close(); throw new MessagingException("Unable to execute POP3 command", e); } }