mail::Mail Class Reference

E-mail representation. More...

#include <mail.h>

List of all members.

Public Types

typedef std::vector< std::string > text_type
enum  { mfAuthenticated = 0x00000001, mfNoQuota = 0x00000002 }
 Send flags. More...
enum  {
  meSuccess = 0x00000000, meIncomplete = 0x00000001, meQuota = 0x00000002, meDelivery = 0x0000004,
  meConfig = 0x00000008, meTemporary = 0x80000000
}
 Error constants. More...

Public Member Functions

 Mail ()
 Constructor.
 Mail (Mail const &m)
 Copy constructor.
Mailoperator= (Mail const &right)
 Assignment operator.
bool send (uint32_t flags, uint32_t *err=0, std::string *errdesc=0)
 Sends the mail.
std::string const & from_name () const
 Returns the name part of the From: field.
std::string const & from_name (std::string const &from_name)
 Sets the name part of the From: field.
std::string const & from_address () const
 Returns the address part of the From: field.
std::string const & from_address (std::string const &from_address)
 Sets the address part of the From: field.
std::string const & subject () const
 Returns the Subject: field.
std::string const & subject (std::string const &subject)
 Sets the Subject: field.
std::string const & sender () const
 Returns the Sender: field.
std::string const & sender (std::string const &sender)
 Sets the Sender: field.
std::string const & to_name () const
 Returns the name part of the To: field.
std::string const & to_name (std::string const &to_name)
 Sets the name part of the To: field.
std::string const & to_address () const
 Returns the address part of the To: field.
std::string const & to_address (std::string const &to_address)
 Sets the address part of the To: field.
std::string const & origin () const
 Returns the X-Origin: field.
std::string const & origin (std::string const &origin)
 Sets the X-Origin: field.
text_type const & text () const
 Returns the vector containing the current text lines.
text_type const & text_add (std::string const &line)
 Adds a line to the e-mail text.
text_type const & text_addf (char const *format,...) FORMAT(printf
 printf-like version of text_add().
text_type const std::string
const & 
data () const
 Returns the mail data.

Static Public Member Functions

static bool configured ()
 Determines whether the mail subsystem has been configured.
static bool valid_address (char const *address, bool noplus)
 Checks for address validity.


Detailed Description

This class represents an e-mail that needs to be sent.


Member Enumeration Documentation

anonymous enum
 

Enumerator:
mfAuthenticated  The target is authenticated.
mfNoQuota  No quota restriction.

anonymous enum
 

Enumerator:
meSuccess  No error.
meIncomplete  The e-mail is incomplete.
meQuota  Quota exceeded.
meDelivery  Delivery error.
meConfig  Mail subsystem not configured.
meTemporary  Is a temporary error.


Member Function Documentation

text_type const std::string const& mail::Mail::data  )  const [inline]
 

Returns the mail data. The data is generated in the send() function and consists of the mail headers and text formatted in a suitable way.

Returns:
The mail data.

std::string const& mail::Mail::origin std::string const &  origin  )  [inline]
 

Sets the X-Origin field. This field is also used by the send() function to determine whether the sender limit has been exceeded.

Parameters:
[in] origin The origin of the e-mail.
Returns:
The new origin of the e-mail.

bool mail::Mail::send uint32_t  flags,
uint32_t *  err = 0,
std::string *  errdesc = 0
 

Sends the mail. Please note that the e-mail is not guaranteed to have been effectively sent when the function returns; mail transport modules are not required to process the mails synchronously. However, the mail object may be deleted once this call has been done, as it is copied as necessary if needed.

The only required field that needs to have been filled before calling this function is to_address(). All other fields are either optional or they have default values.

Parameters:
[in] flags The flags qualifying this sending, which can be one or more of the following:
  • mfAuthenticated: The recipient is an authenticated. e-mail address, so apply limits accordingly.
[out] err If non-NULL, this will be set to a set of the error constants if the function returns false. It is set to meSuccess if there are no errors.
[out] errdesc If non-NULL, is set to a description of the error that just happened.
Returns:
true if the e-mail has been approved, false otherwise.

text_type const& mail::Mail::text_add std::string const &  line  )  [inline]
 

Adds a line to the e-mail text. It must NOT end with a newline character.

Parameters:
[in] line The new line of text to add.
Returns:
The vector containing the current text lines.

static bool mail::Mail::valid_address char const *  address,
bool  noplus
[static]
 

Checks whether an e-mail address is syntaxically valid. The check does not entirely follow RFC 822; we're allowing only a subset of what is (theorically) allowed. However, this should be enough to cover 99,99% of the e-mail addresses commonly in use today while ensuring people don't type in subtly invalid addresses that somehow would still get accepted.

Parameters:
[in] address The address that must be checked.
[in] noplus Set this to true if you want to reject e-mail addresses containing a '+' character in the user part.
Returns:
true if the address is syntaxically valid, false


The documentation for this class was generated from the following file:
Generated on Sun May 20 21:32:20 2007 for Epona API by  doxygen 1.4.6