SMTP: Simple Mail Transfer Protocol
https://en.m.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol
Client API
-
enum SmtpState
Values:
-
enumerator eSMTP_Banner
-
enumerator eSMTP_Hello
-
enumerator eSMTP_StartTLS
-
enumerator eSMTP_SendAuth
-
enumerator eSMTP_SendingAuthLogin
-
enumerator eSMTP_RequestingAuthChallenge
-
enumerator eSMTP_SendAuthResponse
-
enumerator eSMTP_SendingAuth
-
enumerator eSMTP_Ready
-
enumerator eSMTP_SendMail
-
enumerator eSMTP_SendingMail
-
enumerator eSMTP_SendRcpt
-
enumerator eSMTP_SendingRcpt
-
enumerator eSMTP_SendData
-
enumerator eSMTP_SendingData
-
enumerator eSMTP_SendHeader
-
enumerator eSMTP_SendingHeaders
-
enumerator eSMTP_StartBody
-
enumerator eSMTP_SendingBody
-
enumerator eSMTP_Sent
-
enumerator eSMTP_Quitting
-
enumerator eSMTP_Disconnect
-
enumerator eSMTP_Banner
-
using SmtpClientCallback = Delegate<int(SmtpClient &client, int code, char *status)>
-
SMTP_QUEUE_SIZE
-
SMTP_ERROR_LENGTH
-
SMTP_CODE_SERVICE_READY
SMTP response codes
-
SMTP_CODE_BYE
-
SMTP_CODE_AUTH_OK
-
SMTP_CODE_REQUEST_OK
-
SMTP_CODE_AUTH_CHALLENGE
-
SMTP_CODE_START_DATA
-
SMTP_OPT_PIPELINE
-
SMTP_OPT_STARTTLS
-
SMTP_OPT_AUTH_PLAIN
-
SMTP_OPT_AUTH_LOGIN
-
SMTP_OPT_AUTH_CRAM_MD5
-
class MailMessage
- #include <MailMessage.h>
Public Functions
-
inline MailMessage &setHeader(const String &name, const String &value)
Set a header value.
- Parameters:
name –
value –
- Return values:
MailMessage& –
-
HttpHeaders &getHeaders()
Get a reference to the current set of headers.
- Return values:
HttpHeaders& –
-
MailMessage &setBody(const String &body, MimeType mime = MIME_TEXT)
Sets the body of the email.
- Parameters:
body –
mime –
- Return values:
MailMessage& –
-
MailMessage &setBody(String &&body, MimeType mime = MIME_TEXT) noexcept
Sets the body of the email using move semantics.
- Parameters:
body – Will be moved into message then invalidated
mime –
- Return values:
MailMessage& –
-
MailMessage &setBody(IDataSourceStream *stream, MimeType mime = MIME_TEXT)
Sets the body of the email.
- Parameters:
stream –
mime –
- Return values:
MailMessage& –
-
MailMessage &addAttachment(FileStream *stream)
Adds attachment to the email.
- Parameters:
stream –
- Return values:
MailMessage& –
-
MailMessage &addAttachment(IDataSourceStream *stream, MimeType mime, const String &filename = "")
Adds attachment to the email.
- Parameters:
stream –
mime –
filename –
- Return values:
MailMessage& –
-
MailMessage &addAttachment(IDataSourceStream *stream, const String &mime, const String &filename = "")
Adds attachment to the email.
- Parameters:
stream –
mime –
filename –
- Return values:
MailMessage& –
-
inline MailMessage &setHeader(const String &name, const String &value)
-
class SmtpClient : protected TcpClient
- #include <SmtpClient.h>
Unnamed Group
-
bool send(const String &from, const String &to, const String &subject, const String &body)
Queues a single message before it is sent later to the SMTP server.
- Parameters:
from –
to –
subject –
body – The body in plain text format
- Return values:
bool – true when the message was queued successfully, false otherwise
Public Functions
-
bool connect(const Url &url)
Connects to remote URL.
- Parameters:
url – Provides the protocol, remote server, port and user credentials allowed protocols:
smtp - clear text SMTP
smtps - SMTP over SSL connection
-
bool send(MailMessage *message)
Powerful method to queues a single message before it is sent later to the SMTP server.
- Parameters:
message –
- Return values:
bool – true when the message was queued successfully, false otherwise
-
MailMessage *getCurrentMessage()
Gets the current message.
- Return values:
MailMessage* – The message, or NULL if none is scheduled
-
void quit()
Sends a quit command to the server and closes the TCP connection.
-
inline SmtpState getState()
Returns the current state of the SmtpClient.
-
inline void onMessageSent(SmtpClientCallback callback)
Callback that will be called every time a message is sent successfully.
- Parameters:
callback –
-
inline void onServerError(SmtpClientCallback callback)
Callback that will be called every an error occurs.
- Parameters:
callback –
-
bool send(const String &from, const String &to, const String &subject, const String &body)