NetBurner 3.5.0
PDF Version
 
SMTP - Send Email

Topics

 MIME Content Types
 
 SMTP Error Codes
 
 SSL SMTP Functions
 

Functions

int SendMail (IPADDR smtp_server, PCSTR userid, PCSTR from_addr, PCSTR to_addr, PCSTR subject, PCSTR textbody)
 Send an email message. The function will open a TCP connection to the specified SMTP server, create a message based on the parameters, and send the message.
 
int SendMailAuth (IPADDR smtp_server, PCSTR userid, PCSTR pass, PCSTR from_addr, PCSTR to_addr, PCSTR subject, PCSTR textbody)
 Send an email message with plain text authentication. The function will open a TCP connection to the specified SMTP server, create a message based on the parameters, and send the message.
 
int SendMailEx (IPADDR smtp_server, PCSTR userid, PCSTR from_addr_rev_path, PCSTR from_addr_memo_hdr, PCSTR to_addr, PCSTR subject, PCSTR textbody)
 Send an email message function, extended version.
 
int IsMailError ()
 Returns the error status of the last send mail transaction.
 
void PrintNBError (int fd=0)
 If an error occurred, prints the error information received from the SMTP server.
 
void PrintServerLog (int fd=0)
 Prints the server log of the last send mail transaction.
 
int SendMailAuthStartMIME (IPADDR smtp_server, PCSTR userid, PCSTR pass, PCSTR from_addr, PCSTR to_addr, PCSTR subject, int &fd)
 Start a Multi-purpose Internet Mail Extension (MIME)session.
 
int SendMailAuthAddMIME (int fd, int ContentType, const char *pContent, const char *FileName)
 Add a MIME part or attachment to an open MIME Session.
 
int SendMailAuthEndMIME (int fd, PCSTR userid)
 Send a MIME email message and close the SMTP session.
 
enum  CONTENT_TYPE_ENUM {
  CONTENT_TYPE_PLAIN_TEXT , CONTENT_TYPE_PLAIN_TEXT_ATTACH , CONTENT_TYPE_BINARY_ATTACH , CONTENT_TYPE_HTML_DECOMP ,
  CONTENT_TYPE_END
}
 SMTP MIME Conetnet Types. More...
 

Detailed Description

#include< mailto.h >

Send emails using the SMTP specification. The Send Mail functions provide a variety of sending options for simple sending an email, or sending with authentication. The IsMailError function is used to check for errors after an email is sent.

Enumeration Type Documentation

◆ CONTENT_TYPE_ENUM

#include <mailto.h>

SMTP MIME Conetnet Types.

Enumerator
CONTENT_TYPE_PLAIN_TEXT 

Plain text.

CONTENT_TYPE_PLAIN_TEXT_ATTACH 

Plain text attachment.

CONTENT_TYPE_BINARY_ATTACH 

Binary attachment.

CONTENT_TYPE_HTML_DECOMP 

HTML.

CONTENT_TYPE_END 

Additional content types can be added above this line.

Function Documentation

◆ IsMailError()

int IsMailError ( )

#include <mailto.h>

Returns the error status of the last send mail transaction.

Returns
0 if no error occurred, SMTP Error Codes.
See also
PrintNBError(), PrintServerLog()

◆ PrintNBError()

void PrintNBError ( int fd = 0)

#include <mailto.h>

If an error occurred, prints the error information received from the SMTP server.

If an error occurs when sending an email, the system will record the error information received from the SMTP server. The information is only valid for the last transaction.

Parameters
fdIf no parameter is specified information will be sent to stdout. Otherwise it will be sent to the specified file descriptor.
See also
IsMailError(), PrintServerLog()

◆ PrintServerLog()

void PrintServerLog ( int fd = 0)

#include <mailto.h>

Prints the server log of the last send mail transaction.

The results of each send mail transaction are logged to a buffer. This function will send the results of the last transaction to stdout, or the specified file descriptor. The information is only valid for the last transaction.

Parameters
fdIf no parameter is specified information will be sent to stdout. Otherwise it will be sent to the specified file descriptor.
See also
IsMailError(), PrintNBError()

◆ SendMail()

int SendMail ( IPADDR smtp_server,
PCSTR userid,
PCSTR from_addr,
PCSTR to_addr,
PCSTR subject,
PCSTR textbody )

#include <mailto.h>

Send an email message. The function will open a TCP connection to the specified SMTP server, create a message based on the parameters, and send the message.

Parameters
smtp_serverIP address of the destination SMTP server.
useridASCII string representing the RFC 931 identification.
from_addr"From" email address
to_addrDestination email address
subjectEmail subject
textbodyBody of email message
Returns
0 on failure, 1 on success.
See also
SendMailAuth()

◆ SendMailAuth()

int SendMailAuth ( IPADDR smtp_server,
PCSTR userid,
PCSTR pass,
PCSTR from_addr,
PCSTR to_addr,
PCSTR subject,
PCSTR textbody )

#include <mailto.h>

Send an email message with plain text authentication. The function will open a TCP connection to the specified SMTP server, create a message based on the parameters, and send the message.

Send an email message with SMTP plain text authentication per RFC 931. The function will open a TCP connection to the specified SMTP server, authenticate the connection with the specified username and password, create a message based on the parameters, and send the message.

Parameters
smtp_serverIP address of the destination SMTP server.
useridASCII string representing the RFC 931 identification.
passASCII string to provide for AUTH identification.
from_addr"From" email address
to_addrDestination email address
subjectEmail subject
textbodyBody of email message
Returns
0 on failure, 1 on success.
See also
SendMail()

◆ SendMailAuthAddMIME()

int SendMailAuthAddMIME ( int fd,
int ContentType,
const char * pContent,
const char * FileName )

#include <mailto.h>

Add a MIME part or attachment to an open MIME Session.

Must only be called for an open session started with SendMailAuthStartMIME(). It can be called as many times as needed to add each MIME part or attachment to the message.

Parameters
fdThe file descriptor of the open MIME session.
ContentTypeThe MIME content type, such as: CONTENT_TYPE_PLAIN_TEXT, CONTENT_TYPE_PLAIN_TEXT_ATTACH, CONTENT_TYPE_BINARY_ATTACH.
*pContentPointer to the content to add.
*FileNameFile name for the attachment.
Returns
0 on failure, 1 on success.
See also
SendMailAuthStartMIME(), SendMailAuthEndMIME()

◆ SendMailAuthEndMIME()

int SendMailAuthEndMIME ( int fd,
PCSTR userid )

#include <mailto.h>

Send a MIME email message and close the SMTP session.

Must only be called for an open session started with SendMailAuthStartMIME().

Parameters
fdThe file descriptor of the open MIME session.
*useridThe user ID that was used by SendMailAuthStartMIME() to open the session.
Returns
0 on failure, 1 on success.
See also
SendMailAuthStartMIME(), SendMailAuthAddMIME()

◆ SendMailAuthStartMIME()

int SendMailAuthStartMIME ( IPADDR smtp_server,
PCSTR userid,
PCSTR pass,
PCSTR from_addr,
PCSTR to_addr,
PCSTR subject,
int & fd )

#include <mailto.h>

Start a Multi-purpose Internet Mail Extension (MIME)session.

Start a MIME session with plain text password authentication. This function will open a TCP connection to the SMTP server, authenticate, then return while leaving the TCP connection open. The Session file descriptor is returned in the "int &fd" reference variable. This function must be called before any other SendMail MIME function.

Sending an E-Mail message with Multipurpose Internet Mail Extensions (MIME) is a multi step process:

The following MIME types are supported by default. The binary attachment should cover most types such as jpg, gif, etc. The types are defined in \nburn\nbrtos\include\mailto.h, and the functions are implemented in \nburn\system\mailto.cpp.

MIME Content Types defined by MIME Content Types.

Parameters
smtp_serverIP address of the destination SMTP server.
useridASCII string representing the RFC 931 identification.
passPassword.
from_addrReverse path per RFC 821, reverse source route.
to_addrDestination email address.
subjectEmail subject.
fdA �reference� (or pointer) to an integer value of the calling function. The value of fd is modified by this function and will contain the file descriptor for the open SMTP Session. This value must always be checked to be greater than 0 for a valid Session. The fd is passed to other MIME functions to identify the open Session.
Returns
0 on failure, 1 on success.
See also
SendMailAuthAddMIME(), SendMailAuthEndMIME()

◆ SendMailEx()

int SendMailEx ( IPADDR smtp_server,
PCSTR userid,
PCSTR from_addr_rev_path,
PCSTR from_addr_memo_hdr,
PCSTR to_addr,
PCSTR subject,
PCSTR textbody )

#include <mailto.h>

Send an email message function, extended version.

Send an email message with extended parameters. The function will open a TCP connection to the specified SMTP server, create a message based on the parameters, and send the message. This function is identical to SendMail( ), with the addition of the from_addr_rev_path and from_addr_memo_hdr parameters.

Parameters
smtp_serverIP address of the destination SMTP server.
useridASCII string representing the RFC 931 identification.
from_addr_rev_pathReverse path per RFC 821, reverse source route.
from_addr_memo_hdrFrom address memo header per RFC 821. Contains items such as date, subject, to:, CC: and from:.
to_addrDestination email address
subjectEmail subject
textbodyBody of email message
Returns
0 on failure, 1 on success.
See also
SendMail()