SharkSSL™ Embedded SSL/TLS Stack

Detailed Description

This class is a minimal SMTP client that takes an email message body and passes it on to a SMTP server.

Email messages can be used to provide status reports or alarm notifications for embedded devices.

This ANSI C library, is designed as one class with C++ wrapper functions in the header file. Please refer to the following article for more information on Object Oriented programming in C code .

C++ Example code:

SMTP smtp("device1@realtimelogic.com", //const char* from,
"alarmcentral@realtimelogic.com", //const char* to,
"Alarm from device 1", //const char* subject,
"smtp.mandrillapp.com", //const char* smtpServer,
587, //int port,
&sharkSsl,
TRUE, //int startTLS,
"device1@realtimelogic.com", //const char* username,
"mandrill-key", //const char* password
0, //const char* clientDomainName,
"smtp.mandrillapp.com"); //const char* serverDomainName
if(smtp.getEcode() == SMTP_NoError)
if( !smtp.addRecipient("ginfo@realtimelogic.com") )
if( ! smtp.printf("This email was sent at %d\n", time(0)) )
if( !smtp.commit() )
return; //Success.
SMTP_ErrCode eCode = smtp.getEcode();
// Handle error.
SMTP_ErrCode
SMTP error codes.
Definition: SMTP.h:63
@ SMTP_NoError
OK.
Definition: SMTP.h:66
This class is a minimal SMTP client that takes an email message body and passes it on to a SMTP serve...
Definition: SMTP.h:170

#include <SMTP.h>

Public Member Functions

 SMTP (const char *from, const char *to, const char *subject, const char *smtpServer, int port=25, SharkSsl *sharkSsl=0, bool startTLS=false, const char *username=0, const char *password=0, const char *clientDomainName=0, const char *serverDomainName=0, SeCtx *ctx=0)
 Initiate the SMTP email message. More...
 
 ~SMTP ()
 The destructor automatically commits the email if you do not call SMTP::commit. More...
 
int addRecipient (const char *to)
 Optionally add more recipients to this email. More...
 
void setContentType (const char *type)
 Set content-type. More...
 
int write (const char *txt, int len=-1)
 Add body text to email. More...
 
int printf (const char *fmt,...)
 Add body text to email. More...
 
int commit ()
 Commit (send) email. More...
 
SMTP_ErrCode getEcode () const
 Get the error code (SMTP_ErrCode), if any. More...
 
const char * getEmsg ()
 Returns the SMTP error message if any.
 
bool bit8 ()
 Returns true if server supports 8BITMIME. More...
 

Member Function Documentation

◆ bit8()

bool SMTP::bit8 ( )

Returns true if server supports 8BITMIME.

You must make sure you do not send messages not in the seven-bit ASCII character set if this function returns false.

◆ getEcode()

SMTP_ErrCode SMTP::getEcode ( ) const

Get the error code (SMTP_ErrCode), if any.

See also
SMTP::getEmsg