Class SMTPOutputStream

  • All Implemented Interfaces:
    Closeable, Flushable, AutoCloseable

    public class SMTPOutputStream
    extends CRLFOutputStream
    In addition to converting lines into the canonical format, i.e., terminating lines with the CRLF sequence, escapes the "." by adding another "." to any "." that appears in the beginning of a line. See RFC821 section 4.5.2.
    See Also:
    CRLFOutputStream
    • Constructor Detail

      • SMTPOutputStream

        public SMTPOutputStream​(OutputStream os)
    • Method Detail

      • flush

        public void flush()
        Override flush method in FilterOutputStream. The MimeMessage writeTo method flushes its buffer at the end, but we don't want to flush data out to the socket until we've also written the terminating "\r\n.\r\n". We buffer nothing so there's nothing to flush. We depend on the fact that CRLFOutputStream also buffers nothing. SMTPTransport will manually flush the socket before reading the response.
        Specified by:
        flush in interface Flushable
        Overrides:
        flush in class FilterOutputStream
      • ensureAtBOL

        public void ensureAtBOL()
                         throws IOException
        Ensure we're at the beginning of a line. Write CRLF if not.
        Throws:
        IOException - if the write fails