Library: Net
Package: Mail
Header: Poco/Net/SMTPClientSession.h
Description
This class implements an Simple Mail Transfer Procotol (SMTP, RFC 2821) client for sending e-mail messages.
Inheritance
Known Derived Classes: SecureSMTPClientSession
Member Summary
Member Functions: close, getTimeout, isPermanentNegative, isPositiveCompletion, isPositiveIntermediate, isTransientNegative, login, loginUsingCRAM, loginUsingCRAMMD5, loginUsingCRAMSHA1, loginUsingLogin, loginUsingPlain, open, sendCommand, sendMessage, setTimeout, socket
Enumerations
Anonymous
SMTP_PORT = 25
Anonymous
DEFAULT_TIMEOUT = 30000000
LoginMethod
StatusClass
SMTP_POSITIVE_INTERMEDIATE = 3
Constructors
SMTPClientSession
explicit SMTPClientSession(
const StreamSocket & socket
);
Creates the SMTPClientSession using the given socket, which must be connected to a SMTP server.
SMTPClientSession
SMTPClientSession(
const std::string & host,
Poco::UInt16 port = SMTP_PORT
);
Creates the SMTPClientSession using a socket connected to the given host and port.
Destructor
~SMTPClientSession
virtual ~SMTPClientSession();
Destroys the SMTPClientSession.
Member Functions
close
void close();
Sends a QUIT command and closes the connection to the server.
Throws a SMTPException in case of a SMTP-specific error, or a NetException in case of a general network communication failure.
getTimeout
Poco::Timespan getTimeout() const;
Returns the timeout for socket read operations.
login
void login(
const std::string & hostname
);
Greets the SMTP server by sending a EHLO command with the given hostname as argument.
If the server does not understand the EHLO command, a HELO command is sent instead.
Throws a SMTPException in case of a SMTP-specific error, or a NetException in case of a general network communication failure.
login
void login();
Calls login(hostname) with the current host name.
login
void login(
const std::string & hostname,
LoginMethod loginMethod,
const std::string & username,
const std::string & password
);
Logs in to the SMTP server using the given authentication method and the given credentials.
login
void login(
LoginMethod loginMethod,
const std::string & username,
const std::string & password
);
Logs in to the SMTP server using the given authentication method and the given credentials.
open
void open();
Reads the initial response from the SMTP server.
Usually called implicitly through login(), but can also be called explicitly to implement different forms of SMTP authentication.
Does nothing if called more than once.
sendCommand
int sendCommand(
const std::string & command,
std::string & response
);
Sends the given command verbatim to the server and waits for a response.
Throws a SMTPException in case of a SMTP-specific error, or a NetException in case of a general network communication failure.
sendCommand
int sendCommand(
const std::string & command,
const std::string & arg,
std::string & response
);
Sends the given command verbatim to the server and waits for a response.
Throws a SMTPException in case of a SMTP-specific error, or a NetException in case of a general network communication failure.
sendMessage
void sendMessage(
const MailMessage & message
);
Sends the given mail message by sending a MAIL FROM command, a RCPT TO command for every recipient, and a DATA command with the message headers and content.
Throws a SMTPException in case of a SMTP-specific error, or a NetException in case of a general network communication failure.
setTimeout
void setTimeout(
const Poco::Timespan & timeout
);
Sets the timeout for socket read operations.
isPermanentNegative
static bool isPermanentNegative(
int status
);
isPositiveCompletion
static bool isPositiveCompletion(
int status
);
isPositiveIntermediate
static bool isPositiveIntermediate(
int status
);
isTransientNegative
static bool isTransientNegative(
int status
);
login
void login(
const std::string & hostname,
std::string & response
);
loginUsingCRAM
void loginUsingCRAM(
const std::string & username,
const std::string & method,
Poco::DigestEngine & hmac
);
loginUsingCRAMMD5
void loginUsingCRAMMD5(
const std::string & username,
const std::string & password
);
loginUsingCRAMSHA1
void loginUsingCRAMSHA1(
const std::string & username,
const std::string & password
);
loginUsingLogin
void loginUsingLogin(
const std::string & username,
const std::string & password
);
loginUsingPlain
void loginUsingPlain(
const std::string & username,
const std::string & password
);
socket
DialogSocket & socket();