smtp_client Class Reference

#include <smtp_client.h>

Collaboration diagram for smtp_client:

Collaboration graph
[legend]
List of all members.

Public Types

enum  outcomes {
  OKAY = common::OKAY, BAD_INPUT = common::BAD_INPUT, TIMED_OUT = common::TIMED_OUT, ACCESS_DENIED = common::ACCESS_DENIED,
  NO_SERVER = communication_commons::NO_SERVER, NO_CONNECTION = communication_commons::NO_CONNECTION
}

Public Member Functions

 smtp_client ()
 smtp_client (log_base &logging)
virtual ~smtp_client ()
 IMPLEMENT_CLASS_NAME ("smtp_client")
istring text_form () const
 returns a string representation of the information contained here.
void setup_session (const istring &server_name, int smtp_port=SC_SMTP_DEFAULT_PORT, const istring &user_name=istring::empty_string(), const istring &password=istring::empty_string())
 prepares the information about the server and authentication.
void set_server (const istring &server_name)
void set_port (int smtp_port)
void set_auth_user (const istring &user_name)
void set_auth_password (const istring &password)
void set_timeout (int timeout)
 sets the timeout for the smtp client in milliseconds.
void setup_message (const istring &sender_email, const istring &subject, const istring &message_body, const istring &one_recipient=istring::empty_string())
 prepares a message to be sent by setting all the fields.
void set_sender (const istring &sender_email)
void set_subject (const istring &subject)
void set_body (const istring &message_body)
void add_recipient (const istring &recipient)
bool remove_recipient (const istring &recipient)
void clear_recipients ()
void add_carbon (const istring &cc_dest)
bool remove_carbon (const istring &cc_dest)
void clear_carbons ()
outcome send_email ()
 makes a connection to the server and tries to deliver the email.

Static Public Member Functions

static const char * outcome_name (const outcome &to_name)
 returns the textual name of the outcome "to_name".
static istring prune_address (const istring &to_prune, istring &name)
 chops up an address like 'Proper Name <email>' into its parts.
static bool validate_address (const istring &to_check)
 checks the email address "to_check" for validity.

Detailed Description

Definition at line 36 of file smtp_client.h.


Member Enumeration Documentation

enum smtp_client::outcomes

Enumerator:
OKAY  the operation completed successfully, as far as we can tell.
BAD_INPUT  there was a problem with the operation's preconditions; check inputs.
TIMED_OUT  the operation took too long and failed because of it.
ACCESS_DENIED  the authentication information was rejected.
NO_SERVER  the specified server could not be reached.
NO_CONNECTION  there was a problem with the connection to the server.

Definition at line 50 of file smtp_client.h.


Constructor & Destructor Documentation

smtp_client::smtp_client (  ) 

Definition at line 64 of file smtp_client.cpp.

smtp_client::smtp_client ( log_base logging  ) 

Definition at line 79 of file smtp_client.cpp.

smtp_client::~smtp_client (  )  [virtual]

Definition at line 94 of file smtp_client.cpp.

References WHACK().


Member Function Documentation

const char * smtp_client::outcome_name ( const outcome to_name  )  [static]

returns the textual name of the outcome "to_name".

Definition at line 107 of file smtp_client.cpp.

References communication_commons::outcome_name().

smtp_client::IMPLEMENT_CLASS_NAME ( "smtp_client"   ) 

istring smtp_client::text_form (  )  const

returns a string representation of the information contained here.

istring smtp_client::prune_address ( const istring to_prune,
istring name 
) [static]

chops up an address like 'Proper Name <email>' into its parts.

the email address portion is returned as a string. the human readable name is stored into "name".

Definition at line 382 of file smtp_client.cpp.

References istring::end(), istring::find(), non_negative(), istring::substring(), and istring::zap().

Referenced by send_email(), and validate_address().

bool smtp_client::validate_address ( const istring to_check  )  [static]

checks the email address "to_check" for validity.

this includes making sure that there's an @ sign in the email address and not more than one of them and that each side of @ has some non-zero- length content.

Definition at line 354 of file smtp_client.cpp.

References istring::find(), istring::length(), non_negative(), non_positive(), and prune_address().

void smtp_client::setup_session ( const istring server_name,
int  smtp_port = SC_SMTP_DEFAULT_PORT,
const istring user_name = istring::empty_string(),
const istring password = istring::empty_string() 
)

prepares the information about the server and authentication.

setups up the session related information for talking to the smtp server and giving it authentication information, if necessary.

Definition at line 110 of file smtp_client.cpp.

References byte_filer::close(), istring::contains(), byte_filer::eof(), FUNCDEF, byte_filer::getline(), registry_configurator::hkey_current_user, configurator::load(), MAX_LINE, byte_filer::open(), log_base::platform_ending(), configurator::RETURN_ONLY, set_auth_password(), set_auth_user(), set_port(), set_server(), and byte_filer::write().

void smtp_client::set_server ( const istring server_name  ) 

Definition at line 177 of file smtp_client.cpp.

Referenced by setup_session().

void smtp_client::set_port ( int  smtp_port  ) 

Definition at line 180 of file smtp_client.cpp.

Referenced by setup_session().

void smtp_client::set_auth_user ( const istring user_name  ) 

Definition at line 182 of file smtp_client.cpp.

Referenced by setup_session().

void smtp_client::set_auth_password ( const istring password  ) 

Definition at line 185 of file smtp_client.cpp.

Referenced by setup_session().

void smtp_client::set_timeout ( int  timeout  ) 

sets the timeout for the smtp client in milliseconds.

Definition at line 300 of file smtp_client.cpp.

void smtp_client::setup_message ( const istring sender_email,
const istring subject,
const istring message_body,
const istring one_recipient = istring::empty_string() 
)

prepares a message to be sent by setting all the fields.

this method only takes one destination for the email ("one_recipient") but others can be added as necessary with add_recipient(). also, any previous recipients set for the message are cleared by this function.

Definition at line 188 of file smtp_client.cpp.

References add_recipient(), clear_carbons(), clear_recipients(), set_body(), set_sender(), and set_subject().

void smtp_client::set_sender ( const istring sender_email  ) 

Definition at line 254 of file smtp_client.cpp.

Referenced by setup_message().

void smtp_client::set_subject ( const istring subject  ) 

Definition at line 259 of file smtp_client.cpp.

References istring::length(), and istring::s().

Referenced by setup_message().

void smtp_client::set_body ( const istring message_body  ) 

Definition at line 283 of file smtp_client.cpp.

References istring::length(), and istring::s().

Referenced by setup_message().

void smtp_client::add_recipient ( const istring recipient  ) 

Definition at line 200 of file smtp_client.cpp.

Referenced by setup_message().

bool smtp_client::remove_recipient ( const istring recipient  ) 

Definition at line 206 of file smtp_client.cpp.

References array< contents >::get(), array< contents >::length(), and array< contents >::zap().

void smtp_client::clear_recipients (  ) 

Definition at line 222 of file smtp_client.cpp.

References array< contents >::reset().

Referenced by setup_message().

void smtp_client::add_carbon ( const istring cc_dest  ) 

Definition at line 227 of file smtp_client.cpp.

bool smtp_client::remove_carbon ( const istring cc_dest  ) 

Definition at line 233 of file smtp_client.cpp.

References array< contents >::get(), array< contents >::length(), and array< contents >::zap().

void smtp_client::clear_carbons (  ) 

Definition at line 249 of file smtp_client.cpp.

References array< contents >::reset().

Referenced by setup_message().

outcome smtp_client::send_email (  ) 

makes a connection to the server and tries to deliver the email.

the operation will attempt to authenticate with the server. if that succeeds, then the email is handed over to the server with all of the current information. if that succeeds, then OKAY is returned.

Definition at line 412 of file smtp_client.cpp.

References path_configuration::application_directory(), BAD_INPUT, CHECK_FOR_PASSWORD_PROMPT, CHECK_STILL_RUNNING, stdio_redirecter::close_input(), stdio_redirecter::exit_value(), FUNCDEF, array< contents >::get(), stdio_redirecter::health(), istring::length(), array< contents >::length(), LOG, MAXIMUM_PAUSE_FOR_SENDING, MAXIMUM_WRITE_ITERATIONS, array< contents >::observe(), OKAY, stdio_redirecter::OKAY, log_base::platform_ending(), prune_address(), stdio_redirecter::running(), istring::s(), SECOND_ms, portable::sleep_ms(), istring::t(), TIMED_OUT, istring::UNTERMINATED, stdio_redirecter::write(), and istring::zap().


The documentation for this class was generated from the following files:
Generated on Fri Nov 28 04:30:59 2008 for HOOPLE Libraries by  doxygen 1.5.1