class Smtp : public TcpSocket
Sends emails using SMTP protocol.
Smtp& RequestTimeout(int ms)
Total request timeout in milliseconds. Default is 120000 (2 minutes).
Smtp& Host(const String& h)
SMTP host.
Smtp& Port(int p)
SMTP host port. If Null, 25 is used for normal SMTP, 465 for SMTPS (using SSL), and 587 for SMTPS (using STARTTLS).
Smtp& SSL(bool b = true)
Activates SMTPS mode (using SSL).
Requires Core/SSL package.
Smtp& StartTLS(bool b = true)
Activates SMTPS mode (using STARTTLS).
Requires Core/SSL package.
Smtp& Auth(const String& user, const String& pwd)
Sets username and password.
Smtp& From(const String& email, const String& name = Null, const String& sender = Null)
Sets the sender.
Smtp& To(const String& email, const String& name, AS a = TO)
Sets recipient. Can be called multiple times to add any number of recipients. Type of recipient is defined as a, can be one of Smtp::TO, Smtp::BC and Smtp::BCC, correspening to normal email recipient types.
Smtp& To(const String& email, AS a = TO)
Same as To(email, Null, a).
Smtp& Cc(const String& email, const String& name = Null)
Same as To(email, name, Smtp::CC).
Smtp& Bcc(const String& email, const String& name = Null)
Same as To(email, name, Smtp::BCC).
Smtp& ReplyTo(const String& email, const String& name = Null)
Sets the reply address.
Smtp& TimeSent(Time t)
Sets the sent time attribute of email.
Smtp& Subject(const String& s)
Sets the subject of email.
Smtp& Body(const String& s, const String& mime_ = Null)
Adds email body with specified MIME time. Can be called multiple times to add multiple bodies. Null mime_ corresponds to "text/plain" with current default charset.
Smtp& AttachFile(const char *filename, const char *mime = 0)
Attaches a file to email.
Smtp& Attach(const char *name, const String& data, const char *mime = 0)
Attaches a String as file attachment..
Adds additional text message header. Text should not be terminated by CRLF.
Adds additional field id with value txt to header.
Smtp& New()
Restarts Smtp for sending of next email (resets all addresses, bodies, attachments, subject).
String GetMessage()
Returns the message in RFC-822 format, without sending it.
String GetMessageID()
Returns the "Message-ID" header of current message, without "<", ">" characters. New Message ID is generated by constructor or New method. Domain part is taken from message sender; correct result can therefore obtained only after 'From' method was called.
bool Send(const String& message)
Send the raw message in RFC-822 format. Note that sender and recipient of message has to be defined using From, To methods even as they are contained in message.
bool Send()
Sends email. Returns true on success. Same as Send(GetMessage()), except that this form is able to send attachments in chunks.
String GetError() const
Returns description of last error.
Smtp()
Default constructor.
static void Trace(bool b = true)
Activates logging of SMTP.
|