|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--de.trantor.mail.SmtpClient
Encapsulates the SMTP protocol, as specified in RFC 822. This class is used to send messages across the internet. After an SMTP session has been established using the open() method, an arbitrary number of messages can be sent using the two variants of the sendMessage() method. One variant sends a message already contained in an envelope, the other one creates the envelope on-the-fly. Each SMTP session should be terminated by a call to the close() method.
Pop3Client,
Envelope,
Message| Constructor Summary | |
SmtpClient(Connection connection,
java.lang.String localhost)
|
|
SmtpClient(java.lang.String localhost)
Constructs an instance of the SMTP client. |
|
| Method Summary | |
void |
close()
Ends the SMTP session. |
boolean |
connected()
Returns true, if the client is currently connected to an SMTP server. |
boolean |
getDebug()
Queries whether the SMTP client is in debug mode or not. |
void |
open(java.lang.String host)
Opens a connection to the given server at the well-known port 25. |
void |
open(java.lang.String host,
int port,
boolean ssl,
java.lang.String user,
java.lang.String pass)
Opens a connection to the given server at the given port and using secure sockets, if desired. |
void |
sendMessage(Envelope envelope)
Sends a message. |
void |
sendMessage(Message message)
Sends a message. |
void |
setDebug(boolean value)
Controls printing of protocol debugging information to standard output. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public SmtpClient(java.lang.String localhost)
Some explanation might be handy here, since the localhost parameter seems to be a source of confusion: Actually, there is *some* value needed during initial SMTP handshaking. The SMTP specification says that this value should identify the client machine, but most servers don't seem to actually use the passed value, but check the client's IP number instead (if it checks something at all). Yet, it is possible that there are hosts that allow access only to "known" clients based on this value. So, in most cases passing null or "localhost" will be ok. If you run into problems with a specific host, try to pass a sensible value here.
public SmtpClient(Connection connection,
java.lang.String localhost)
| Method Detail |
public void open(java.lang.String host)
throws java.io.IOException,
MailException
java.io.IOException
MailExceptionopen(String, int, boolean, String, String),
close(),
connected()
public void open(java.lang.String host,
int port,
boolean ssl,
java.lang.String user,
java.lang.String pass)
throws java.io.IOException,
MailException
A note on authentication: It requires an ESMTP server that actually allows authentication. Only the PLAIN method is supported, which expects the username and password information to be passed in one MIME-encoded string. Other methods are too costly in terms of code, so they're not supported (yet).
java.io.IOException
MailExceptionopen(String),
close(),
connected()
public void close()
throws java.io.IOException,
MailException
java.io.IOException
MailExceptionopen(java.lang.String),
connected()public boolean connected()
open(java.lang.String),
close()
public void sendMessage(Message message)
throws java.io.IOException,
MailException
java.io.IOException
MailExceptionsendMessage(de.trantor.mail.Envelope),
Envelope,
Message
public void sendMessage(Envelope envelope)
throws java.io.IOException,
MailException
java.io.IOException
MailExceptionsendMessage(de.trantor.mail.Message),
Envelope,
Messagepublic boolean getDebug()
public void setDebug(boolean value)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||