Send email to an SMTP server. More...
#include "config.h"
#include <arpa/inet.h>
#include <netdb.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <unistd.h>
#include "mutt/lib.h"
#include "address/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "conn/lib.h"
#include "smtp.h"
#include "progress/lib.h"
#include "question/lib.h"
#include "globals.h"
#include "mutt_account.h"
#include "mutt_socket.h"
#include "sendlib.h"
Go to the source code of this file.
Data Structures | |
struct | SmtpAccountData |
Server connection data. More... | |
struct | SmtpAuth |
SMTP authentication multiplexor. More... | |
Macros | |
#define | smtp_success(x) (((x) / 100) == 2) |
#define | SMTP_READY 334 |
#define | SMTP_CONTINUE 354 |
#define | SMTP_ERR_READ -2 |
#define | SMTP_ERR_WRITE -3 |
#define | SMTP_ERR_CODE -4 |
#define | SMTP_PORT 25 |
#define | SMTPS_PORT 465 |
#define | SMTP_AUTH_SUCCESS 0 |
#define | SMTP_AUTH_UNAVAIL 1 |
#define | SMTP_AUTH_FAIL -1 |
#define | SMTP_CAP_NO_FLAGS 0 |
No flags are set. | |
#define | SMTP_CAP_STARTTLS (1 << 0) |
Server supports STARTTLS command. | |
#define | SMTP_CAP_AUTH (1 << 1) |
Server supports AUTH command. | |
#define | SMTP_CAP_DSN (1 << 2) |
Server supports Delivery Status Notification. | |
#define | SMTP_CAP_EIGHTBITMIME (1 << 3) |
Server supports 8-bit MIME content. | |
#define | SMTP_CAP_SMTPUTF8 (1 << 4) |
Server accepts UTF-8 strings. | |
#define | SMTP_CAP_ALL ((1 << 5) - 1) |
Typedefs | |
typedef uint8_t | SmtpCapFlags |
SMTP server capabilities. | |
Functions | |
static bool | valid_smtp_code (char *buf, int *n) |
Is the is a valid SMTP return code? | |
static int | smtp_get_resp (struct SmtpAccountData *adata) |
Read a command response from the SMTP server. | |
static int | smtp_rcpt_to (struct SmtpAccountData *adata, const struct AddressList *al) |
Set the recipient to an Address. | |
static int | smtp_data (struct SmtpAccountData *adata, const char *msgfile) |
Send data to an SMTP server. | |
static const char * | smtp_get_field (enum ConnAccountField field, void *gf_data) |
Get connection login credentials - Implements ConnAccount::get_field() -. | |
static int | smtp_fill_account (struct SmtpAccountData *adata, struct ConnAccount *cac) |
Create ConnAccount object from SMTP Url. | |
static int | smtp_helo (struct SmtpAccountData *adata, bool esmtp) |
Say hello to an SMTP Server. | |
static int | smtp_auth_oauth_xoauth2 (struct SmtpAccountData *adata, const char *method, bool xoauth2) |
Authenticate an SMTP connection using OAUTHBEARER/XOAUTH2. | |
static int | smtp_auth_oauth (struct SmtpAccountData *adata, const char *method) |
Authenticate an SMTP connection using OAUTHBEARER - Implements SmtpAuth::authenticate() -. | |
static int | smtp_auth_xoauth2 (struct SmtpAccountData *adata, const char *method) |
Authenticate an SMTP connection using XOAUTH2 - Implements SmtpAuth::authenticate() -. | |
static int | smtp_auth_plain (struct SmtpAccountData *adata, const char *method) |
Authenticate using plain text - Implements SmtpAuth::authenticate() -. | |
static int | smtp_auth_login (struct SmtpAccountData *adata, const char *method) |
Authenticate using plain text - Implements SmtpAuth::authenticate() -. | |
bool | smtp_auth_is_valid (const char *authenticator) |
Check if string is a valid smtp authentication method. | |
static int | smtp_authenticate (struct SmtpAccountData *adata) |
Authenticate to an SMTP server. | |
static int | smtp_open (struct SmtpAccountData *adata, bool esmtp) |
Open an SMTP Connection. | |
int | mutt_smtp_send (const struct AddressList *from, const struct AddressList *to, const struct AddressList *cc, const struct AddressList *bcc, const char *msgfile, bool eightbit, struct ConfigSubset *sub) |
Send a message using SMTP. | |
Variables | |
static const struct SmtpAuth | SmtpAuthenticators [] |
Accepted authentication methods. | |
Send email to an SMTP server.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file smtp.c.
#define SMTP_CAP_STARTTLS (1 << 0) |
#define SMTP_CAP_DSN (1 << 2) |
#define SMTP_CAP_EIGHTBITMIME (1 << 3) |
#define SMTP_CAP_SMTPUTF8 (1 << 4) |
typedef uint8_t SmtpCapFlags |
|
static |
Is the is a valid SMTP return code?
[in] | buf | String to check |
[out] | n | Numeric value of code |
true | Valid number |
Definition at line 130 of file smtp.c.
|
static |
Read a command response from the SMTP server.
adata | SMTP Account data |
0 | Success (2xx code) or continue (354 code) |
-1 | Write error, or any other response code |
Definition at line 141 of file smtp.c.
|
static |
Set the recipient to an Address.
adata | SMTP Account data |
al | AddressList to use |
0 | Success |
<0 | Error, e.g. SMTP_ERR_WRITE |
Definition at line 199 of file smtp.c.
|
static |
Send data to an SMTP server.
adata | SMTP Account data |
msgfile | Filename containing data |
0 | Success |
<0 | Error, e.g. SMTP_ERR_WRITE |
Definition at line 241 of file smtp.c.
|
static |
Create ConnAccount object from SMTP Url.
adata | SMTP Account data |
cac | ConnAccount to populate |
0 | Success |
-1 | Error |
Definition at line 359 of file smtp.c.
|
static |
Say hello to an SMTP Server.
adata | SMTP Account data |
esmtp | If true, use ESMTP |
0 | Success |
<0 | Error, e.g. SMTP_ERR_WRITE |
Definition at line 415 of file smtp.c.
|
static |
Authenticate an SMTP connection using OAUTHBEARER/XOAUTH2.
adata | SMTP Account data |
method | Authentication method |
xoauth2 | Use XOAUTH2 token (if true), OAUTHBEARER token otherwise |
num | Result, e.g. SMTP_AUTH_SUCCESS |
Definition at line 733 of file smtp.c.
bool smtp_auth_is_valid | ( | const char * | authenticator | ) |
Check if string is a valid smtp authentication method.
authenticator | Authenticator string to check |
true | Argument is a valid auth method |
Validate whether an input string is an accepted smtp authentication method as defined by SmtpAuthenticators.
Definition at line 927 of file smtp.c.
|
static |
Authenticate to an SMTP server.
adata | SMTP Account data |
0 | Success |
<0 | Error, e.g. SMTP_AUTH_FAIL |
Definition at line 945 of file smtp.c.
|
static |
Open an SMTP Connection.
adata | SMTP Account data |
esmtp | If true, use ESMTP |
0 | Success |
-1 | Error |
Definition at line 1018 of file smtp.c.
int mutt_smtp_send | ( | const struct AddressList * | from, |
const struct AddressList * | to, | ||
const struct AddressList * | cc, | ||
const struct AddressList * | bcc, | ||
const char * | msgfile, | ||
bool | eightbit, | ||
struct ConfigSubset * | sub | ||
) |
Send a message using SMTP.
from | From Address |
to | To Address |
cc | Cc Address |
bcc | Bcc Address |
msgfile | Message to send to the server |
eightbit | If true, try for an 8-bit friendly connection |
sub | Config Subset |
0 | Success |
-1 | Error |
Definition at line 1100 of file smtp.c.
|
static |
Accepted authentication methods.