|
smtp-client
SMTP Client C Library
|
POSIX mailx utility. More...
#include <err.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include "smtp.h"
Include dependency graph for mailx.c:Go to the source code of this file.
Data Structures | |
| struct | mailx_address |
| struct | mailx_attachment |
| struct | mailx |
Macros | |
| #define | _POSIX_C_SOURCE 200809L |
Functions | |
| static char * | smtp_ffile_get_contents (FILE *stream, size_t *bytes_read) |
| static void | mailx_address_append (struct mailx *const mailx, enum smtp_address_type address_type, const char *const email) |
| static void | mailx_send (struct mailx *const mailx) |
| static void | mailx_append_attachment (struct mailx *const mailx, const char *const filename, const char *const path) |
| static void | mailx_append_attachment_arg (struct mailx *const mailx, const char *const attach_arg) |
| static void | mailx_parse_smtp_option (struct mailx *const mailx, const char *const option) |
| static void | mailx_init_default_values (struct mailx *const mailx) |
| static void | mailx_free (const struct mailx *const mailx) |
| int | main (int argc, char *argv[]) |
POSIX mailx utility.
Implementation of POSIX mailx utility in send mode.
mailx [-s subject] [[-S option]...] [[-a attachment]...] address...
This software has been placed into the public domain using CC0.
Definition in file mailx.c.
| #define _POSIX_C_SOURCE 200809L |
|
static |
Append this email to the list of email addresses to send to.
| [in] | mailx | Append the email address into this mailx context. |
| [in] | address_type | See smtp_address_type. |
| [in] | Email address to send to. |
Definition at line 200 of file mailx.c.
References mailx::address_list, mailx_address::address_type, mailx_address::email, mailx::num_address, and realloc.
Referenced by main().
Here is the caller graph for this function:
|
static |
Attach a file to the mailx context.
| [in] | mailx | Store the attachment details into this mailx context. |
| [in] | filename | File name to display to the recipient. |
| [in] | path | Local path of file to attach. |
Definition at line 270 of file mailx.c.
References mailx::attachment_list, mailx_attachment::name, mailx::num_attachment, mailx_attachment::path, and realloc.
Referenced by mailx_append_attachment_arg().
Here is the caller graph for this function:
|
static |
Parse the file name and path and attach it to the mailx context.
| [in] | mailx | Store the attachment details into this mailx context. |
| [in] | attach_arg | String with format: 'filename:filepath'. |
Definition at line 303 of file mailx.c.
References mailx_append_attachment().
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Frees the allocated memory associated with the mailx context.
| [in] | mailx | The mailx context to free. |
Definition at line 452 of file mailx.c.
References mailx::body, mailx::from, mailx::pass, mailx::port, mailx::server, and mailx::user.
Referenced by main().
Here is the caller graph for this function:
|
static |
Initialize and set the default options in the mailx context.
See description of -S argument in main for more details.
| [in] | mailx | The mailx content to initialize. |
Definition at line 439 of file mailx.c.
References mailx::auth_method, mailx::connection_security, SMTP_AUTH_NONE, SMTP_SECURITY_NONE, and mailx::subject.
Referenced by main().
Here is the caller graph for this function:
|
static |
Parses the -S option which contains a key/value pair separated by an '=' character.
| [in] | mailx | Store the results of the option parsing into the relevant field in this mailx context. |
| [in] | option | String containing key/value option to parse. |
Definition at line 330 of file mailx.c.
References mailx::auth_method, mailx::connection_security, mailx::from, mailx::pass, mailx::port, mailx::server, SMTP_AUTH_CRAM_MD5, SMTP_AUTH_LOGIN, SMTP_AUTH_NONE, SMTP_AUTH_PLAIN, SMTP_DEBUG, mailx::smtp_flags, SMTP_NO_CERT_VERIFY, SMTP_SECURITY_NONE, SMTP_SECURITY_STARTTLS, SMTP_SECURITY_TLS, and mailx::user.
Referenced by main().
Here is the caller graph for this function:
|
static |
Send the email using the configuration options in the mailx context.
| [in] | mailx | Email context. |
Definition at line 225 of file mailx.c.
References mailx::address_list, mailx_address::address_type, mailx::attachment_list, mailx::auth_method, mailx::body, mailx::connection_security, mailx_address::email, mailx_attachment::name, mailx::num_address, mailx::num_attachment, mailx::pass, mailx_attachment::path, mailx::port, mailx::server, mailx::smtp, smtp_address_add(), smtp_attachment_add_path(), smtp_auth(), smtp_close(), mailx::smtp_flags, smtp_header_add(), smtp_mail(), smtp_open(), smtp_status_code_errstr(), SMTP_STATUS_OK, mailx::subject, and mailx::user.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Main program entry point for the mailx utility.
This program supports the following options:
The following list contains possible options for the -S argument:
The following list shows the default option for -S argument if not provided:
| [in] | argc | Number of arguments in argv. |
| [in] | argv | String array containing the program name and any optional parameters described above. |
| 0 | Email has been sent. |
| 1 | An error occurred while sending email. Although unlikely, an email can still get sent even after returning with this error code. |
Definition at line 498 of file mailx.c.
References mailx::body, mailx::from, mailx_address_append(), mailx_append_attachment_arg(), mailx_free(), mailx_init_default_values(), mailx_parse_smtp_option(), mailx_send(), mailx::port, mailx::server, SMTP_ADDRESS_FROM, SMTP_ADDRESS_TO, smtp_ffile_get_contents(), and mailx::subject.
Here is the call graph for this function:
|
static |
Read the entire contents of a file stream and store the data into a dynamically allocated buffer.
| [in] | stream | File stream already opened by the caller. |
| [out] | bytes_read | Number of bytes stored in the return buffer. |
| char* | A dynamically allocated buffer which contains the entire contents of stream. The caller must free this memory when done. |
| NULL | Memory allocation or file read error. |
Definition at line 153 of file mailx.c.
References ferror, and realloc.
Referenced by main().
Here is the caller graph for this function: