|
smtp-client
SMTP Client C Library
|
#include <SMTPMail.h>
Collaboration diagram for SMTPMail:Public Member Functions | |
| SMTPMail (void) | |
| ~SMTPMail (void) | |
| void | open (const char *const server, const char *const port, enum smtp_connection_security connection_security, enum smtp_flag flags, const char *const cafile) |
| void | auth (enum smtp_authentication_method auth_method, const char *const user, const char *const pass) |
| void | mail (const char *const body) |
| void | close (void) |
| int | status_code_get (void) |
| void | status_code_set (enum smtp_status_code new_status_code) |
| void | header_add (const char *const key, const char *const value) |
| void | header_clear_all (void) |
| void | address_add (enum smtp_address_type type, const char *const email, const char *const name) |
| void | address_clear_all (void) |
| void | attachment_add_path (const char *const name, const char *const path) |
| void | attachment_add_fp (const char *const name, FILE *fp) |
| void | attachment_add_mem (const char *const name, const void *const data, ssize_t datasz) |
| void | attachment_clear_all (void) |
Private Member Functions | |
| void | throw_bad_status_code (void) |
Private Attributes | |
| struct smtp * | smtp |
| enum smtp_status_code | rc |
Thin CPP wrapper class over the smtp-client C library.
Definition at line 53 of file SMTPMail.h.
| SMTPMail::SMTPMail | ( | void | ) |
| SMTPMail::~SMTPMail | ( | void | ) |
| void SMTPMail::address_add | ( | enum smtp_address_type | type, |
| const char *const | email, | ||
| const char *const | name | ||
| ) |
Add a FROM, TO, CC, or BCC address destination to this SMTP context.
See smtp_address_add.
| [in] | type | See smtp_address_type. |
| [in] | The email address of the party. Must consist only of printable characters excluding the angle brackets (<) and (>). | |
| [in] | name | Name or description of the party. Must consist only of printable characters, excluding the quote characters. If set to NULL, no name will get associated with this email. |
Definition at line 78 of file SMTPMail.cpp.
References smtp_address_add().
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| void SMTPMail::address_clear_all | ( | void | ) |
Free all memory related to the address list.
Definition at line 85 of file SMTPMail.cpp.
References smtp_address_clear_all().
Here is the call graph for this function:| void SMTPMail::attachment_add_fp | ( | const char *const | name, |
| FILE * | fp | ||
| ) |
Add an attachment using a file pointer.
| [in] | name | Filename of the attachment shown to recipients. |
| [in] | fp | File pointer already opened by the caller. |
Definition at line 95 of file SMTPMail.cpp.
References smtp_attachment_add_fp().
Here is the call graph for this function:| void SMTPMail::attachment_add_mem | ( | const char *const | name, |
| const void *const | data, | ||
| ssize_t | datasz | ||
| ) |
Add an attachment with the data pulled from memory.
| [in] | name | Filename of the attachment shown to recipients. Must consist only of printable characters excluding the quote characters (') and ("), or the space character ( ). |
| [in] | data | Raw attachment data stored in memory. |
| [in] | datasz | Number of bytes in data, or -1 if data null-terminated. |
Definition at line 101 of file SMTPMail.cpp.
References smtp_attachment_add_mem().
Here is the call graph for this function:| void SMTPMail::attachment_add_path | ( | const char *const | name, |
| const char *const | path | ||
| ) |
Add a file attachment from a path.
| [in] | name | Filename of the attachment shown to recipients. |
| [in] | path | Path of file location to read from. |
Definition at line 89 of file SMTPMail.cpp.
References smtp_attachment_add_path().
Here is the call graph for this function:| void SMTPMail::attachment_clear_all | ( | void | ) |
Remove all attachments from the SMTP client context.
See smtp_attachment_clear_all.
Definition at line 108 of file SMTPMail.cpp.
References smtp_attachment_clear_all().
Here is the call graph for this function:| void SMTPMail::auth | ( | enum smtp_authentication_method | auth_method, |
| const char *const | user, | ||
| const char *const | pass | ||
| ) |
Authenticate the user using one of the methods listed in smtp_authentication_method.
See smtp_auth.
| [in] | auth_method | See smtp_authentication_method. |
| [in] | user | Server authentication user name. |
| [in] | pass | Server authentication user password. |
Definition at line 42 of file SMTPMail.cpp.
References smtp_auth().
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| void SMTPMail::close | ( | void | ) |
Close the SMTP connection and frees all resources held by the SMTP context.
See smtp_close.
Definition at line 54 of file SMTPMail.cpp.
References smtp_close().
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| void SMTPMail::header_add | ( | const char *const | key, |
| const char *const | value | ||
| ) |
Add a key/value header to the header list in the SMTP context.
See smtp_header_add.
| [in] | key | Key name for new header. It must consist only of printable US-ASCII characters except colon. |
| [in] | value | Value for new header. It must consist only of printable US-ASCII, space, or horizontal tab. If set to NULL, this will prevent the header from printing out. |
Definition at line 68 of file SMTPMail.cpp.
References smtp_header_add().
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| void SMTPMail::header_clear_all | ( | void | ) |
Free all memory related to email headers.
Definition at line 74 of file SMTPMail.cpp.
References smtp_header_clear_all().
Here is the call graph for this function:| void SMTPMail::mail | ( | const char *const | body | ) |
Sends an email using the addresses, attachments, and headers defined in the current SMTP context.
See smtp_mail.
| [in] | body | Null-terminated string to send in the email body. |
Definition at line 49 of file SMTPMail.cpp.
References smtp_mail().
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| void SMTPMail::open | ( | const char *const | server, |
| const char *const | port, | ||
| enum smtp_connection_security | connection_security, | ||
| enum smtp_flag | flags, | ||
| const char *const | cafile | ||
| ) |
Open a connection to an SMTP server.
See smtp_open.
| [in] | server | Server name or IP address. |
| [in] | port | Server port number. |
| [in] | connection_security | See smtp_connection_security. |
| [in] | flags | See smtp_flag. |
| [in] | cafile | Path to certificate file, or NULL to use certificates in the default path. |
Definition at line 28 of file SMTPMail.cpp.
References smtp_open().
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| int SMTPMail::status_code_get | ( | void | ) |
Get the current status/error code described in smtp_status_code.
See smtp_status_code_get.
Definition at line 59 of file SMTPMail.cpp.
References smtp_status_code_get().
Here is the call graph for this function:| void SMTPMail::status_code_set | ( | enum smtp_status_code | new_status_code | ) |
Set the error status of the SMTP client context.
See smtp_status_code_set.
| [in] | new_status_code | See smtp_status_code. |
Definition at line 63 of file SMTPMail.cpp.
References smtp_status_code_set().
Here is the call graph for this function:
|
private |
Throw SMTPMailException if the last smtp-client library function failed.
Definition at line 112 of file SMTPMail.cpp.
References SMTP_STATUS_OK, and SMTPMailException::SMTPMailException().
Here is the call graph for this function:
|
private |
Store the last smtp-client library function return code.
Definition at line 233 of file SMTPMail.h.
|
private |
SMTP client context.
Definition at line 228 of file SMTPMail.h.