smtpsocket Class Reference

SMTP client class. More...

#include <smtp.h>

Collaboration diagram for smtpsocket:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 smtpsocket (void)
 ~smtpsocket (void)
void setsmtphost (const string &hostname, int port=25)
void setsender (const string &address, const string &name)
void setsender (const string &address)
bool sendmessage (const value &rcptto, const string &subject, const string &body, const string &mailfrom, const string &contenttype)
bool sendmessage (const value &rcptto, const string &subject, const string &body, const string &mailfrom)
bool sendmessage (const value &rcptto, const string &subject, const string &body)
void setheader (const statstring &name, const string &val)
const stringerror (void)
int errorcode (void)
bool dosmtp (const value &rcptto, const string &body)

Protected Attributes

string smtphost
int smtpport
string sender
string sendername
string hostname
value headers
string err
int erno

Detailed Description

SMTP client class.

Implements the SMTP protocol for sending email through a server.


Constructor & Destructor Documentation

smtpsocket::smtpsocket ( void   ) 

Constructor.

Defaults the SMTP connection to localhost and the sender address to the current username with the system hostname as the email domain.

References erno, systemclass::userdbFunctions::getpwuid(), systemclass::userdbFunctions::getuid(), systemclass::netFunctions::hostname(), hostname, systemclass::net, setsender(), setsmtphost(), and systemclass::userdb.

Here is the call graph for this function:

smtpsocket::~smtpsocket ( void   ) 

Destructor.

Boring, since it doesn't involve any acts of blowing things up.


Member Function Documentation

bool smtpsocket::dosmtp ( const value rcptto,
const string body 
)

Act on an SMTP transaction.

Assumes all proper headers and properties have been set.

References file::close(), tcpsocket::connect(), value::count(), erno, err, value::exists(), file::gets(), headers, hostname, file::puts(), strutil::regexp(), sender, sendername, smtphost, smtpport, string::strcat(), value::sval(), and string::toint().

Referenced by sendmessage().

Here is the call graph for this function:

bool smtpsocket::sendmessage ( const value rcptto,
const string subject,
const string body 
)

Dispatch an SMTP message.

Parameters:
rcptto Recipient(s). Can be either an array of one or more string objects containing recipient addresses or a string object containing a single email address.
subject The email subject.
body The email body.

References dosmtp(), and setheader().

Here is the call graph for this function:

bool smtpsocket::sendmessage ( const value rcptto,
const string subject,
const string body,
const string mailfrom 
)

Dispatch an SMTP message.

Parameters:
rcptto Recipient(s). Can be either an array of one or more string objects containing recipient addresses or a string object containing a single email address.
subject The email subject.
body The email body.
mailfrom The sender address.

References dosmtp(), setheader(), and setsender().

Here is the call graph for this function:

bool smtpsocket::sendmessage ( const value rcptto,
const string subject,
const string body,
const string mailfrom,
const string contenttype 
)

Dispatch an SMTP message.

Parameters:
rcptto Recipient(s). Can be either an array of one or more string objects containing recipient addresses or a string object containing a single email address.
subject The email subject.
body The email body.
mailfrom The sender address.
contenttype The body content-type.

References dosmtp(), setheader(), and setsender().

Here is the call graph for this function:

void smtpsocket::setheader ( const statstring name,
const string val 
)

Set an outgoing mail header.

Parameters:
name The header name.
val The header value.

References headers.

Referenced by sendmessage().

void smtpsocket::setsender ( const string address  ) 

Sets the email sender.

Expects an email address either in the raw form or the RFC name+email form:

The first form will default to a name of "Mail System" if the sender address is used in the From header.

References string::chomp(), string::cropat(), sender, sendername, strutil::splitquoted(), and string::strchr().

Here is the call graph for this function:

void smtpsocket::setsender ( const string address,
const string name 
)

Sets the email sender.

If no separate From header is supplied this will also be supplied as the From-address.

Parameters:
address The email address.
name The sender's name.

References sender, and sendername.

Referenced by sendmessage(), and smtpsocket().

void smtpsocket::setsmtphost ( const string hostname,
int  port = 25 
)

Sets the address of the SMTP server.

Parameters:
hostname SMTP hostname.
port SMTP tcp port defaults to 25.

References smtphost, and smtpport.

Referenced by smtpsocket().


The documentation for this class was generated from the following files:

Generated on Sun Feb 28 10:36:22 2010 for GRACE by  doxygen 1.6.1