#include <mail.h>
Public Types | |
enum | { mfAuthenticated = 0x00000001, mfNoQuota = 0x00000002 } |
Send flags. More... | |
enum | { meSuccess = 0x00000000, meIncomplete = 0x00000001, meQuota = 0x00000002, meDelivery = 0x0000004, meConfig = 0x00000008, meTemporary = 0x80000000 } |
Error constants. More... | |
typedef std::vector< std::string > | text_type |
Public Member Functions | |
Mail () | |
Constructor. | |
Mail (Mail const &m) | |
Copy constructor. | |
Mail & | operator= (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. |
anonymous enum |
anonymous enum |
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. |
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.
[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. |
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.
[in] | flags | The flags qualifying this sending, which can be one or more of the following:
|
[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. |
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.
[in] | origin | The origin of the e-mail. |
text_type const& mail::Mail::text_add | ( | std::string const & | line | ) |
Adds a line to the e-mail text. A newline is automatically added at the end of the text if it is missing. Also, if there are newlines in the middle of the text, they will be treated accordingly.
[in] | line | The new line of text to add. |
text_type const std::string const& mail::Mail::data | ( | ) | const [inline] |