Class SmtpClient


  • public class SmtpClient
    extends TransferProtocolClient
    This class implements the SMTP client. You can send a piece of mail by creating a new SmtpClient, calling the "to" method to add destinations, calling "from" to name the sender, calling startMessage to return a stream to which you write the message (with RFC733 headers) and then you finally close the Smtp Client.
    Version:
    1.17, 12 Dec 1994
    Author:
    James Gosling
    • Constructor Detail

      • SmtpClient

        public SmtpClient​(java.lang.String host)
                   throws java.io.IOException
        New SMTP client connected to host host.
        Throws:
        java.io.IOException
      • SmtpClient

        public SmtpClient()
                   throws java.io.IOException
        Create an uninitialized SMTP client.
        Throws:
        java.io.IOException
    • Method Detail

      • closeServer

        public void closeServer()
                         throws java.io.IOException
        issue the QUIT command to the SMTP server and close the connection.
        Overrides:
        closeServer in class NetworkClient
        Throws:
        java.io.IOException
      • to

        public void to​(java.lang.String s)
                throws java.io.IOException
        Throws:
        java.io.IOException
      • from

        public void from​(java.lang.String s)
                  throws java.io.IOException
        Throws:
        java.io.IOException
      • startMessage

        public java.io.PrintStream startMessage()
                                         throws java.io.IOException
        Throws:
        java.io.IOException