#include <smtp_client.h>
Collaboration diagram for smtp_client:

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. | |
Definition at line 36 of file smtp_client.h.
Definition at line 50 of file smtp_client.h.
| 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] |
| 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.
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 | ) |
| void smtp_client::set_port | ( | int | smtp_port | ) |
| void smtp_client::set_auth_user | ( | const istring & | user_name | ) |
| void smtp_client::set_auth_password | ( | const istring & | password | ) |
| 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 | ) |
| 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 | ) |
| 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().
1.5.1