APIdia Launch Partner
Top Description Fields Constructors Methods
sun.net.smtp

public Class SmtpClient

Additional top-level class in compilation unit: SmtpPrintStream.

extends TransferProtocolClient
Class Inheritance
Imports
java.io.*, java.net.*, sun.net.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.
Author
James Gosling

Field Summary

Modifier and TypeField and Description
private static int
pack-priv String
pack-priv SmtpPrintStream
Inherited from sun.net.TransferProtocolClient:
lastReplyCodeserverResponse

Constructor Summary

AccessConstructor and Description
public
SmtpClient(String host)

New SMTP client connected to host host.

public
SmtpClient()

Create an uninitialized SMTP client.

public
SmtpClient(int to)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
public void
closeServer()

Overrides sun.net.NetworkClient.closeServer.

issue the QUIT command to the SMTP server and close the connection.

public void
pack-priv String
public String
pack-priv void
issueCommand(String cmd, int expect)

private void
openServer(String host)

open a SMTP connection to host host.

public PrintStream
public void
private void
Inherited from sun.net.TransferProtocolClient:
getResponseStringgetResponseStringsreadServerResponsesendServer

Field Detail

DEFAULT_SMTP_PORTback to summary
private static int DEFAULT_SMTP_PORT
mailhostback to summary
pack-priv String mailhost
messageback to summary
pack-priv SmtpPrintStream message

Constructor Detail

SmtpClientback to summary
public SmtpClient(String host) throws IOException

New SMTP client connected to host host.

SmtpClientback to summary
public SmtpClient() throws IOException

Create an uninitialized SMTP client.

SmtpClientback to summary
public SmtpClient(int to) throws IOException

Method Detail

closeMessageback to summary
pack-priv void closeMessage() throws IOException
closeServerback to summary
public void closeServer() throws IOException

Overrides sun.net.NetworkClient.closeServer.

issue the QUIT command to the SMTP server and close the connection.

fromback to summary
public void from(String s) throws IOException
getEncodingback to summary
pack-priv String getEncoding()
getMailHostback to summary
public String getMailHost()
issueCommandback to summary
pack-priv void issueCommand(String cmd, int expect) throws IOException
openServerback to summary
private void openServer(String host) throws IOException

open a SMTP connection to host host.

startMessageback to summary
public PrintStream startMessage() throws IOException
toback to summary
public void to(String s) throws IOException
toCanonicalback to summary
private void toCanonical(String s) throws IOException