SMTP: Simple Mail Transfer Protocol¶
https://en.m.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol
Client API¶
-
enum
smtpclient
::
SmtpState
¶ Values:
-
eSMTP_Banner
= 0¶
-
eSMTP_Hello
¶
-
eSMTP_StartTLS
¶
-
eSMTP_SendAuth
¶
-
eSMTP_SendingAuthLogin
¶
-
eSMTP_RequestingAuthChallenge
¶
-
eSMTP_SendAuthResponse
¶
-
eSMTP_SendingAuth
¶
-
eSMTP_Ready
¶
-
eSMTP_SendMail
¶
-
eSMTP_SendingMail
¶
-
eSMTP_SendRcpt
¶
-
eSMTP_SendingRcpt
¶
-
eSMTP_SendData
¶
-
eSMTP_SendingData
¶
-
eSMTP_SendHeader
¶
-
eSMTP_SendingHeaders
¶
-
eSMTP_StartBody
¶
-
eSMTP_SendingBody
¶
-
eSMTP_Sent
¶
-
eSMTP_Quitting
¶
-
eSMTP_Disconnect
¶
-
-
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
-
MailMessage &
setHeader
(const String &name, const String &value)¶ Set a header value.
- Parameters
name
:value
:
- Return Value
MailMessage&
:
-
HttpHeaders &
getHeaders
()¶ Get a reference to the current set of headers.
- Return Value
HttpHeaders&
:
-
MailMessage &
setBody
(const String &body, MimeType mime = MIME_TEXT)¶ Sets the body of the email.
- Parameters
body
:mime
:
- Return Value
MailMessage&
:
-
MailMessage &
setBody
(String &&body, MimeType mime = MIME_TEXT)¶ Sets the body of the email using move semantics.
- Parameters
body
: Will be moved into message then invalidatedmime
:
- Return Value
MailMessage&
:
-
MailMessage &
setBody
(IDataSourceStream *stream, MimeType mime = MIME_TEXT)¶ Sets the body of the email.
- Parameters
stream
:mime
:
- Return Value
MailMessage&
:
-
MailMessage &
addAttachment
(FileStream *stream)¶ Adds attachment to the email.
- Parameters
stream
:
- Return Value
MailMessage&
:
-
MailMessage &
addAttachment
(IDataSourceStream *stream, MimeType mime, const String &filename = "")¶ Adds attachment to the email.
- Parameters
stream
:mime
:filename
:
- Return Value
MailMessage&
:
-
MailMessage &
addAttachment
(IDataSourceStream *stream, const String &mime, const String &filename = "")¶ Adds attachment to the email.
- Parameters
stream
:mime
:filename
:
- Return Value
MailMessage&
:
-
MailMessage &
-
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 Value
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 Value
bool
: true when the message was queued successfully, false otherwise
-
MailMessage *
getCurrentMessage
()¶ Gets the current message.
- Return Value
MailMessage*
: The message, or NULL if none is scheduled
-
void
quit
()¶ Sends a quit command to the server and closes the TCP conneciton.
-
SmtpState
getState
()¶ Returns the current state of the SmtpClient.
-
void
onMessageSent
(SmtpClientCallback callback)¶ Callback that will be called every time a message is sent successfully.
- Parameters
callback
:
-
void
onServerError
(SmtpClientCallback callback)¶ Callback that will be called every an error occurs.
- Parameters
callback
:
-
bool