NeoMutt  2023-03-22
Teaching an old dog new tricks
DOXYGEN
smtp.c File Reference

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 <string.h>
#include <unistd.h>
#include "mutt/lib.h"
#include "address/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "conn/lib.h"
#include "smtp.h"
#include "lib.h"
#include "progress/lib.h"
#include "question/lib.h"
#include "globals.h"
#include "mutt_account.h"
#include "mutt_socket.h"
+ Include dependency graph for smtp.c:

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. More...
 
#define SMTP_CAP_STARTTLS   (1 << 0)
 Server supports STARTTLS command. More...
 
#define SMTP_CAP_AUTH   (1 << 1)
 Server supports AUTH command. More...
 
#define SMTP_CAP_DSN   (1 << 2)
 Server supports Delivery Status Notification. More...
 
#define SMTP_CAP_EIGHTBITMIME   (1 << 3)
 Server supports 8-bit MIME content. More...
 
#define SMTP_CAP_SMTPUTF8   (1 << 4)
 Server accepts UTF-8 strings. More...
 
#define SMTP_CAP_ALL   ((1 << 5) - 1)
 

Typedefs

typedef uint8_t SmtpCapFlags
 SMTP server capabilities. More...
 

Functions

static bool valid_smtp_code (char *buf, size_t buflen, int *n)
 Is the is a valid SMTP return code? More...
 
static int smtp_get_resp (struct SmtpAccountData *adata)
 Read a command response from the SMTP server. More...
 
static int smtp_rcpt_to (struct SmtpAccountData *adata, const struct AddressList *al)
 Set the recipient to an Address. More...
 
static int smtp_data (struct SmtpAccountData *adata, const char *msgfile)
 Send data to an SMTP server. More...
 
static const char * smtp_get_field (enum ConnAccountField field, void *gf_data)
 Get connection login credentials - Implements ConnAccount::get_field() More...
 
static int smtp_fill_account (struct SmtpAccountData *adata, struct ConnAccount *cac)
 Create ConnAccount object from SMTP Url. More...
 
static int smtp_helo (struct SmtpAccountData *adata, bool esmtp)
 Say hello to an SMTP Server. More...
 
static int smtp_auth_oauth_xoauth2 (struct SmtpAccountData *adata, const char *method, bool xoauth2)
 Authenticate an SMTP connection using OAUTHBEARER/XOAUTH2. More...
 
static int smtp_auth_oauth (struct SmtpAccountData *adata, const char *method)
 Authenticate an SMTP connection using OAUTHBEARER. More...
 
static int smtp_auth_xoauth2 (struct SmtpAccountData *adata, const char *method)
 Authenticate an SMTP connection using XOAUTH2. More...
 
static int smtp_auth_plain (struct SmtpAccountData *adata, const char *method)
 Authenticate using plain text. More...
 
static int smtp_auth_login (struct SmtpAccountData *adata, const char *method)
 Authenticate using plain text. More...
 
bool smtp_auth_is_valid (const char *authenticator)
 Check if string is a valid smtp authentication method. More...
 
static int smtp_authenticate (struct SmtpAccountData *adata)
 Authenticate to an SMTP server. More...
 
static int smtp_open (struct SmtpAccountData *adata, bool esmtp)
 Open an SMTP Connection. More...
 
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. More...
 

Variables

static const struct SmtpAuth SmtpAuthenticators []
 Accepted authentication methods. More...
 

Detailed Description

Send email to an SMTP server.

Authors
  • Michael R. Elkins
  • Brendan Cully
  • Pietro Cerutti

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.

Macro Definition Documentation

◆ smtp_success

#define smtp_success (   x)    ((x) / 100 == 2)

Definition at line 61 of file smtp.c.

◆ SMTP_READY

#define SMTP_READY   334

Definition at line 62 of file smtp.c.

◆ SMTP_CONTINUE

#define SMTP_CONTINUE   354

Definition at line 63 of file smtp.c.

◆ SMTP_ERR_READ

#define SMTP_ERR_READ   -2

Definition at line 65 of file smtp.c.

◆ SMTP_ERR_WRITE

#define SMTP_ERR_WRITE   -3

Definition at line 66 of file smtp.c.

◆ SMTP_ERR_CODE

#define SMTP_ERR_CODE   -4

Definition at line 67 of file smtp.c.

◆ SMTP_PORT

#define SMTP_PORT   25

Definition at line 69 of file smtp.c.

◆ SMTPS_PORT

#define SMTPS_PORT   465

Definition at line 70 of file smtp.c.

◆ SMTP_AUTH_SUCCESS

#define SMTP_AUTH_SUCCESS   0

Definition at line 72 of file smtp.c.

◆ SMTP_AUTH_UNAVAIL

#define SMTP_AUTH_UNAVAIL   1

Definition at line 73 of file smtp.c.

◆ SMTP_AUTH_FAIL

#define SMTP_AUTH_FAIL   -1

Definition at line 74 of file smtp.c.

◆ SMTP_CAP_NO_FLAGS

#define SMTP_CAP_NO_FLAGS   0

No flags are set.

Definition at line 81 of file smtp.c.

◆ SMTP_CAP_STARTTLS

#define SMTP_CAP_STARTTLS   (1 << 0)

Server supports STARTTLS command.

Definition at line 82 of file smtp.c.

◆ SMTP_CAP_AUTH

#define SMTP_CAP_AUTH   (1 << 1)

Server supports AUTH command.

Definition at line 83 of file smtp.c.

◆ SMTP_CAP_DSN

#define SMTP_CAP_DSN   (1 << 2)

Server supports Delivery Status Notification.

Definition at line 84 of file smtp.c.

◆ SMTP_CAP_EIGHTBITMIME

#define SMTP_CAP_EIGHTBITMIME   (1 << 3)

Server supports 8-bit MIME content.

Definition at line 85 of file smtp.c.

◆ SMTP_CAP_SMTPUTF8

#define SMTP_CAP_SMTPUTF8   (1 << 4)

Server accepts UTF-8 strings.

Definition at line 86 of file smtp.c.

◆ SMTP_CAP_ALL

#define SMTP_CAP_ALL   ((1 << 5) - 1)

Definition at line 88 of file smtp.c.

Typedef Documentation

◆ SmtpCapFlags

typedef uint8_t SmtpCapFlags

SMTP server capabilities.

Flags, e.g. SMTP_CAP_STARTTLS

Definition at line 80 of file smtp.c.

Function Documentation

◆ valid_smtp_code()

static bool valid_smtp_code ( char *  buf,
size_t  buflen,
int *  n 
)
static

Is the is a valid SMTP return code?

Parameters
[in]bufString to check
[in]buflenLength of string
[out]nNumeric value of code
Return values
trueValid number

Definition at line 127 of file smtp.c.

128{
129 return (mutt_str_atoi(buf, n) - buf) <= 3;
130}
const char * mutt_str_atoi(const char *str, int *dst)
Convert ASCII string to an integer.
Definition: atoi.c:179
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ smtp_get_resp()

static int smtp_get_resp ( struct SmtpAccountData adata)
static

Read a command response from the SMTP server.

Parameters
adataSMTP Account data
Return values
0Success (2xx code) or continue (354 code)
-1Write error, or any other response code

Definition at line 138 of file smtp.c.

139{
140 int n;
141 char buf[1024] = { 0 };
142
143 do
144 {
145 n = mutt_socket_readln(buf, sizeof(buf), adata->conn);
146 if (n < 4)
147 {
148 /* read error, or no response code */
149 return SMTP_ERR_READ;
150 }
151 const char *s = buf + 4; /* Skip the response code and the space/dash */
152 size_t plen;
153
154 if (mutt_istr_startswith(s, "8BITMIME"))
156 else if ((plen = mutt_istr_startswith(s, "AUTH ")))
157 {
158 adata->capabilities |= SMTP_CAP_AUTH;
159 FREE(&adata->auth_mechs);
160 adata->auth_mechs = mutt_str_dup(s + plen);
161 }
162 else if (mutt_istr_startswith(s, "DSN"))
163 adata->capabilities |= SMTP_CAP_DSN;
164 else if (mutt_istr_startswith(s, "STARTTLS"))
166 else if (mutt_istr_startswith(s, "SMTPUTF8"))
168
169 if (!valid_smtp_code(buf, n, &n))
170 return SMTP_ERR_CODE;
171
172 } while (buf[3] == '-');
173
174 if (smtp_success(n) || (n == SMTP_CONTINUE))
175 return 0;
176
177 mutt_error(_("SMTP session failed: %s"), buf);
178 return -1;
179}
#define mutt_error(...)
Definition: logging.h:87
#define FREE(x)
Definition: memory.h:43
#define _(a)
Definition: message.h:28
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:250
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
Definition: string.c:239
static size_t plen
Length of cached packet.
Definition: pgppacket.c:39
#define SMTP_CAP_STARTTLS
Server supports STARTTLS command.
Definition: smtp.c:82
#define SMTP_ERR_READ
Definition: smtp.c:65
#define SMTP_ERR_CODE
Definition: smtp.c:67
#define SMTP_CAP_EIGHTBITMIME
Server supports 8-bit MIME content.
Definition: smtp.c:85
#define smtp_success(x)
Definition: smtp.c:61
#define SMTP_CAP_AUTH
Server supports AUTH command.
Definition: smtp.c:83
#define SMTP_CAP_SMTPUTF8
Server accepts UTF-8 strings.
Definition: smtp.c:86
#define SMTP_CONTINUE
Definition: smtp.c:63
#define SMTP_CAP_DSN
Server supports Delivery Status Notification.
Definition: smtp.c:84
static bool valid_smtp_code(char *buf, size_t buflen, int *n)
Is the is a valid SMTP return code?
Definition: smtp.c:127
#define mutt_socket_readln(buf, buflen, conn)
Definition: socket.h:58
struct Connection * conn
Server Connection.
Definition: smtp.c:98
const char * auth_mechs
Allowed authorisation mechanisms.
Definition: smtp.c:96
SmtpCapFlags capabilities
Server capabilities.
Definition: smtp.c:97
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ smtp_rcpt_to()

static int smtp_rcpt_to ( struct SmtpAccountData adata,
const struct AddressList *  al 
)
static

Set the recipient to an Address.

Parameters
adataSMTP Account data
alAddressList to use
Return values
0Success
<0Error, e.g. SMTP_ERR_WRITE

Definition at line 188 of file smtp.c.

189{
190 if (!al)
191 return 0;
192
193 const char *const c_dsn_notify = cs_subset_string(adata->sub, "dsn_notify");
194
195 struct Address *a = NULL;
196 TAILQ_FOREACH(a, al, entries)
197 {
198 /* weed out group mailboxes, since those are for display only */
199 if (!a->mailbox || a->group)
200 {
201 continue;
202 }
203 char buf[1024] = { 0 };
204 if ((adata->capabilities & SMTP_CAP_DSN) && c_dsn_notify)
205 snprintf(buf, sizeof(buf), "RCPT TO:<%s> NOTIFY=%s\r\n", a->mailbox, c_dsn_notify);
206 else
207 snprintf(buf, sizeof(buf), "RCPT TO:<%s>\r\n", a->mailbox);
208 if (mutt_socket_send(adata->conn, buf) == -1)
209 return SMTP_ERR_WRITE;
210 int rc = smtp_get_resp(adata);
211 if (rc != 0)
212 return rc;
213 }
214
215 return 0;
216}
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:317
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:725
static int smtp_get_resp(struct SmtpAccountData *adata)
Read a command response from the SMTP server.
Definition: smtp.c:138
#define SMTP_ERR_WRITE
Definition: smtp.c:66
#define mutt_socket_send(conn, buf)
Definition: socket.h:59
An email address.
Definition: address.h:36
bool group
Group mailbox?
Definition: address.h:39
char * mailbox
Mailbox and host address.
Definition: address.h:38
struct ConfigSubset * sub
Config scope.
Definition: smtp.c:99
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ smtp_data()

static int smtp_data ( struct SmtpAccountData adata,
const char *  msgfile 
)
static

Send data to an SMTP server.

Parameters
adataSMTP Account data
msgfileFilename containing data
Return values
0Success
<0Error, e.g. SMTP_ERR_WRITE

Definition at line 225 of file smtp.c.

226{
227 char buf[1024] = { 0 };
228 struct Progress *progress = NULL;
229 int rc = SMTP_ERR_WRITE;
230 int term = 0;
231 size_t buflen = 0;
232
233 FILE *fp = fopen(msgfile, "r");
234 if (!fp)
235 {
236 mutt_error(_("SMTP session failed: unable to open %s"), msgfile);
237 return -1;
238 }
239 const long size = mutt_file_get_size_fp(fp);
240 if (size == 0)
241 {
242 mutt_file_fclose(&fp);
243 return -1;
244 }
245 unlink(msgfile);
246 progress = progress_new(_("Sending message..."), MUTT_PROGRESS_NET, size);
247
248 snprintf(buf, sizeof(buf), "DATA\r\n");
249 if (mutt_socket_send(adata->conn, buf) == -1)
250 {
251 mutt_file_fclose(&fp);
252 goto done;
253 }
254 rc = smtp_get_resp(adata);
255 if (rc != 0)
256 {
257 mutt_file_fclose(&fp);
258 goto done;
259 }
260
261 rc = SMTP_ERR_WRITE;
262 while (fgets(buf, sizeof(buf) - 1, fp))
263 {
264 buflen = mutt_str_len(buf);
265 term = buflen && buf[buflen - 1] == '\n';
266 if (term && ((buflen == 1) || (buf[buflen - 2] != '\r')))
267 snprintf(buf + buflen - 1, sizeof(buf) - buflen + 1, "\r\n");
268 if (buf[0] == '.')
269 {
270 if (mutt_socket_send_d(adata->conn, ".", MUTT_SOCK_LOG_FULL) == -1)
271 {
272 mutt_file_fclose(&fp);
273 goto done;
274 }
275 }
276 if (mutt_socket_send_d(adata->conn, buf, MUTT_SOCK_LOG_FULL) == -1)
277 {
278 mutt_file_fclose(&fp);
279 goto done;
280 }
281 progress_update(progress, MAX(0, ftell(fp)), -1);
282 }
283 if (!term && buflen &&
284 (mutt_socket_send_d(adata->conn, "\r\n", MUTT_SOCK_LOG_FULL) == -1))
285 {
286 mutt_file_fclose(&fp);
287 goto done;
288 }
289 mutt_file_fclose(&fp);
290
291 /* terminate the message body */
292 if (mutt_socket_send(adata->conn, ".\r\n") == -1)
293 goto done;
294
295 rc = smtp_get_resp(adata);
296
297done:
298 progress_free(&progress);
299 return rc;
300}
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:151
long mutt_file_get_size_fp(FILE *fp)
Get the size of a file.
Definition: file.c:1585
#define MAX(a, b)
Definition: memory.h:30
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definition: string.c:567
@ MUTT_PROGRESS_NET
Progress tracks bytes, according to $net_inc
Definition: lib.h:51
void progress_free(struct Progress **ptr)
Free a Progress Bar.
Definition: progress.c:86
bool progress_update(struct Progress *progress, size_t pos, int percent)
Update the state of the progress bar.
Definition: progress.c:73
struct Progress * progress_new(const char *msg, enum ProgressType type, size_t size)
Create a new Progress Bar.
Definition: progress.c:118
#define MUTT_SOCK_LOG_FULL
Definition: socket.h:56
#define mutt_socket_send_d(conn, buf, dbg)
Definition: socket.h:60
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ smtp_get_field()

static const char * smtp_get_field ( enum ConnAccountField  field,
void *  gf_data 
)
static

Get connection login credentials - Implements ConnAccount::get_field()

Definition at line 305 of file smtp.c.

306{
307 struct SmtpAccountData *adata = gf_data;
308 if (!adata)
309 return NULL;
310
311 switch (field)
312 {
313 case MUTT_CA_LOGIN:
314 case MUTT_CA_USER:
315 {
316 const char *const c_smtp_user = cs_subset_string(adata->sub, "smtp_user");
317 return c_smtp_user;
318 }
319 case MUTT_CA_PASS:
320 {
321 const char *const c_smtp_pass = cs_subset_string(adata->sub, "smtp_pass");
322 return c_smtp_pass;
323 }
325 {
326 const char *const c_smtp_oauth_refresh_command = cs_subset_string(adata->sub, "smtp_oauth_refresh_command");
327 return c_smtp_oauth_refresh_command;
328 }
329 case MUTT_CA_HOST:
330 default:
331 return NULL;
332 }
333}
@ MUTT_CA_OAUTH_CMD
OAuth refresh command.
Definition: connaccount.h:38
@ MUTT_CA_USER
User name.
Definition: connaccount.h:36
@ MUTT_CA_LOGIN
Login name.
Definition: connaccount.h:35
@ MUTT_CA_HOST
Server name.
Definition: connaccount.h:34
@ MUTT_CA_PASS
Password.
Definition: connaccount.h:37
Server connection data.
Definition: smtp.c:95
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ smtp_fill_account()

static int smtp_fill_account ( struct SmtpAccountData adata,
struct ConnAccount cac 
)
static

Create ConnAccount object from SMTP Url.

Parameters
adataSMTP Account data
cacConnAccount to populate
Return values
0Success
-1Error

Definition at line 342 of file smtp.c.

343{
344 cac->flags = 0;
345 cac->port = 0;
347 cac->service = "smtp";
349 cac->gf_data = adata;
350
351 const char *const c_smtp_url = cs_subset_string(adata->sub, "smtp_url");
352
353 struct Url *url = url_parse(c_smtp_url);
354 if (!url || ((url->scheme != U_SMTP) && (url->scheme != U_SMTPS)) ||
355 !url->host || (mutt_account_fromurl(cac, url) < 0))
356 {
357 url_free(&url);
358 mutt_error(_("Invalid SMTP URL: %s"), c_smtp_url);
359 return -1;
360 }
361
362 if (url->scheme == U_SMTPS)
363 cac->flags |= MUTT_ACCT_SSL;
364
365 if (cac->port == 0)
366 {
367 if (cac->flags & MUTT_ACCT_SSL)
368 cac->port = SMTPS_PORT;
369 else
370 {
371 static unsigned short SmtpPort = 0;
372 if (SmtpPort == 0)
373 {
374 struct servent *service = getservbyname("smtp", "tcp");
375 if (service)
376 SmtpPort = ntohs(service->s_port);
377 else
378 SmtpPort = SMTP_PORT;
379 mutt_debug(LL_DEBUG3, "Using default SMTP port %d\n", SmtpPort);
380 }
381 cac->port = SmtpPort;
382 }
383 }
384
385 url_free(&url);
386 return 0;
387}
#define MUTT_ACCT_SSL
Account uses SSL/TLS.
Definition: connaccount.h:47
#define mutt_debug(LEVEL,...)
Definition: logging.h:84
@ LL_DEBUG3
Log at debug level 3.
Definition: logging.h:42
int mutt_account_fromurl(struct ConnAccount *cac, const struct Url *url)
Fill ConnAccount with information from url.
Definition: mutt_account.c:43
@ MUTT_ACCT_TYPE_SMTP
Smtp Account.
Definition: mutt_account.h:39
#define SMTPS_PORT
Definition: smtp.c:70
static const char * smtp_get_field(enum ConnAccountField field, void *gf_data)
Get connection login credentials - Implements ConnAccount::get_field()
Definition: smtp.c:305
#define SMTP_PORT
Definition: smtp.c:69
const char * service
Name of the service, e.g. "imap".
Definition: connaccount.h:61
const char *(* get_field)(enum ConnAccountField field, void *gf_data)
Function to get some login credentials.
Definition: connaccount.h:68
unsigned char type
Connection type, e.g. MUTT_ACCT_TYPE_IMAP.
Definition: connaccount.h:59
MuttAccountFlags flags
Which fields are initialised, e.g. MUTT_ACCT_USER.
Definition: connaccount.h:60
void * gf_data
Private data to pass to get_field()
Definition: connaccount.h:70
unsigned short port
Port to connect to.
Definition: connaccount.h:58
A parsed URL proto://user:password@host:port/path?a=1&b=2
Definition: url.h:69
char * host
Host.
Definition: url.h:73
enum UrlScheme scheme
Scheme, e.g. U_SMTPS.
Definition: url.h:70
struct Url * url_parse(const char *src)
Fill in Url.
Definition: url.c:234
void url_free(struct Url **ptr)
Free the contents of a URL.
Definition: url.c:123
@ U_SMTPS
Url is smtps://.
Definition: url.h:44
@ U_SMTP
Url is smtp://.
Definition: url.h:43
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ smtp_helo()

static int smtp_helo ( struct SmtpAccountData adata,
bool  esmtp 
)
static

Say hello to an SMTP Server.

Parameters
adataSMTP Account data
esmtpIf true, use ESMTP
Return values
0Success
<0Error, e.g. SMTP_ERR_WRITE

Definition at line 396 of file smtp.c.

397{
399
400 if (!esmtp)
401 {
402 /* if TLS or AUTH are requested, use EHLO */
403 if (adata->conn->account.flags & MUTT_ACCT_USER)
404 esmtp = true;
405#ifdef USE_SSL
406 const bool c_ssl_force_tls = cs_subset_bool(adata->sub, "ssl_force_tls");
407 const enum QuadOption c_ssl_starttls = cs_subset_quad(adata->sub, "ssl_starttls");
408
409 if (c_ssl_force_tls || (c_ssl_starttls != MUTT_NO))
410 esmtp = true;
411#endif
412 }
413
414 char buf[1024] = { 0 };
415 snprintf(buf, sizeof(buf), "%s %s\r\n", esmtp ? "EHLO" : "HELO", adata->fqdn);
416 /* XXX there should probably be a wrapper in mutt_socket.c that
417 * repeatedly calls adata->conn->write until all data is sent. This
418 * currently doesn't check for a short write. */
419 if (mutt_socket_send(adata->conn, buf) == -1)
420 return SMTP_ERR_WRITE;
421 return smtp_get_resp(adata);
422}
enum QuadOption cs_subset_quad(const struct ConfigSubset *sub, const char *name)
Get a quad-value config item by name.
Definition: helpers.c:218
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
#define MUTT_ACCT_USER
User field has been set.
Definition: connaccount.h:44
QuadOption
Possible values for a quad-option.
Definition: quad.h:36
@ MUTT_NO
User answered 'No', or assume 'No'.
Definition: quad.h:38
#define SMTP_CAP_NO_FLAGS
No flags are set.
Definition: smtp.c:81
struct ConnAccount account
Account details: username, password, etc.
Definition: connection.h:50
const char * fqdn
Fully-qualified domain name.
Definition: smtp.c:100
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ smtp_auth_oauth_xoauth2()

static int smtp_auth_oauth_xoauth2 ( struct SmtpAccountData adata,
const char *  method,
bool  xoauth2 
)
static

Authenticate an SMTP connection using OAUTHBEARER/XOAUTH2.

Parameters
adataSMTP Account data
methodAuthentication method (not used)
xoauth2Use XOAUTH2 token (if true), OAUTHBEARER token otherwise
Return values
numResult, e.g. SMTP_AUTH_SUCCESS

Definition at line 721 of file smtp.c.

722{
723 (void) method; // This is OAUTHBEARER
724 const char *authtype = xoauth2 ? "XOAUTH2" : "OAUTHBEARER";
725
726 // L10N: (%s) is the method name, e.g. Anonymous, CRAM-MD5, GSSAPI, SASL
727 mutt_message(_("Authenticating (%s)..."), authtype);
728
729 /* We get the access token from the smtp_oauth_refresh_command */
730 char *oauthbearer = mutt_account_getoauthbearer(&adata->conn->account, xoauth2);
731 if (!oauthbearer)
732 return SMTP_AUTH_FAIL;
733
734 size_t ilen = strlen(oauthbearer) + 30;
735 char *ibuf = mutt_mem_malloc(ilen);
736 snprintf(ibuf, ilen, "AUTH %s %s\r\n", authtype, oauthbearer);
737
738 int rc = mutt_socket_send(adata->conn, ibuf);
739 FREE(&oauthbearer);
740 FREE(&ibuf);
741
742 if (rc == -1)
743 return SMTP_AUTH_FAIL;
744 if (smtp_get_resp(adata) != 0)
745 return SMTP_AUTH_FAIL;
746
747 return SMTP_AUTH_SUCCESS;
748}
char * mutt_account_getoauthbearer(struct ConnAccount *cac, bool xoauth2)
Get an OAUTHBEARER/XOAUTH2 token.
Definition: connaccount.c:194
#define mutt_message(...)
Definition: logging.h:86
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Definition: memory.c:90
#define SMTP_AUTH_FAIL
Definition: smtp.c:74
#define SMTP_AUTH_SUCCESS
Definition: smtp.c:72
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ smtp_auth_oauth()

static int smtp_auth_oauth ( struct SmtpAccountData adata,
const char *  method 
)
static

Authenticate an SMTP connection using OAUTHBEARER.

Parameters
adataSMTP Account data
methodAuthentication method (not used)
Return values
numResult, e.g. SMTP_AUTH_SUCCESS

Definition at line 756 of file smtp.c.

757{
758 return smtp_auth_oauth_xoauth2(adata, method, false);
759}
static int smtp_auth_oauth_xoauth2(struct SmtpAccountData *adata, const char *method, bool xoauth2)
Authenticate an SMTP connection using OAUTHBEARER/XOAUTH2.
Definition: smtp.c:721
+ Here is the call graph for this function:

◆ smtp_auth_xoauth2()

static int smtp_auth_xoauth2 ( struct SmtpAccountData adata,
const char *  method 
)
static

Authenticate an SMTP connection using XOAUTH2.

Parameters
adataSMTP Account data
methodAuthentication method (not used)
Return values
numResult, e.g. SMTP_AUTH_SUCCESS

Definition at line 767 of file smtp.c.

768{
769 return smtp_auth_oauth_xoauth2(adata, method, true);
770}
+ Here is the call graph for this function:

◆ smtp_auth_plain()

static int smtp_auth_plain ( struct SmtpAccountData adata,
const char *  method 
)
static

Authenticate using plain text.

Parameters
adataSMTP Account data
methodAuthentication method (not used)
Return values
0Success
<0Error, e.g. SMTP_AUTH_FAIL

Definition at line 779 of file smtp.c.

780{
781 (void) method; // This is PLAIN
782
783 char buf[1024] = { 0 };
784
785 /* Get username and password. Bail out of any can't be retrieved. */
786 if ((mutt_account_getuser(&adata->conn->account) < 0) ||
787 (mutt_account_getpass(&adata->conn->account) < 0))
788 {
789 goto error;
790 }
791
792 /* Build the initial client response. */
793 size_t len = mutt_sasl_plain_msg(buf, sizeof(buf), "AUTH PLAIN",
794 adata->conn->account.user,
795 adata->conn->account.user,
796 adata->conn->account.pass);
797
798 /* Terminate as per SMTP protocol. Bail out if there's no room left. */
799 if (snprintf(buf + len, sizeof(buf) - len, "\r\n") != 2)
800 {
801 goto error;
802 }
803
804 /* Send request, receive response (with a check for OK code). */
805 if ((mutt_socket_send(adata->conn, buf) < 0) || smtp_get_resp(adata))
806 {
807 goto error;
808 }
809
810 /* If we got here, auth was successful. */
811 return 0;
812
813error:
814 // L10N: %s is the method name, e.g. Anonymous, CRAM-MD5, GSSAPI, SASL
815 mutt_error(_("%s authentication failed"), "SASL");
816 return -1;
817}
int mutt_account_getpass(struct ConnAccount *cac)
Fetch password into ConnAccount, if necessary.
Definition: connaccount.c:129
int mutt_account_getuser(struct ConnAccount *cac)
Retrieve username into ConnAccount, if necessary.
Definition: connaccount.c:49
size_t mutt_sasl_plain_msg(char *buf, size_t buflen, const char *cmd, const char *authz, const char *user, const char *pass)
Construct a base64 encoded SASL PLAIN message.
Definition: sasl_plain.c:55
char user[128]
Username.
Definition: connaccount.h:56
char pass[256]
Password.
Definition: connaccount.h:57
+ Here is the call graph for this function:

◆ smtp_auth_login()

static int smtp_auth_login ( struct SmtpAccountData adata,
const char *  method 
)
static

Authenticate using plain text.

Parameters
adataSMTP Account data
methodAuthentication method (not used)
Return values
0Success
<0Error, e.g. SMTP_AUTH_FAIL

Definition at line 826 of file smtp.c.

827{
828 (void) method; // This is LOGIN
829
830 char b64[1024] = { 0 };
831 char buf[1026] = { 0 };
832
833 /* Get username and password. Bail out of any can't be retrieved. */
834 if ((mutt_account_getuser(&adata->conn->account) < 0) ||
835 (mutt_account_getpass(&adata->conn->account) < 0))
836 {
837 goto error;
838 }
839
840 /* Send the AUTH LOGIN request. */
841 if (mutt_socket_send(adata->conn, "AUTH LOGIN\r\n") < 0)
842 {
843 goto error;
844 }
845
846 /* Read the 334 VXNlcm5hbWU6 challenge ("Username:" base64-encoded) */
847 mutt_socket_readln_d(buf, sizeof(buf), adata->conn, MUTT_SOCK_LOG_FULL);
848 if (!mutt_str_equal(buf, "334 VXNlcm5hbWU6"))
849 {
850 goto error;
851 }
852
853 /* Send the username */
854 size_t len = snprintf(buf, sizeof(buf), "%s", adata->conn->account.user);
855 mutt_b64_encode(buf, len, b64, sizeof(b64));
856 snprintf(buf, sizeof(buf), "%s\r\n", b64);
857 if (mutt_socket_send(adata->conn, buf) < 0)
858 {
859 goto error;
860 }
861
862 /* Read the 334 UGFzc3dvcmQ6 challenge ("Password:" base64-encoded) */
863 mutt_socket_readln_d(buf, sizeof(buf), adata->conn, MUTT_SOCK_LOG_FULL);
864 if (!mutt_str_equal(buf, "334 UGFzc3dvcmQ6"))
865 {
866 goto error;
867 }
868
869 /* Send the password */
870 len = snprintf(buf, sizeof(buf), "%s", adata->conn->account.pass);
871 mutt_b64_encode(buf, len, b64, sizeof(b64));
872 snprintf(buf, sizeof(buf), "%s\r\n", b64);
873 if (mutt_socket_send(adata->conn, buf) < 0)
874 {
875 goto error;
876 }
877
878 /* Check the final response */
879 if (smtp_get_resp(adata) < 0)
880 {
881 goto error;
882 }
883
884 /* If we got here, auth was successful. */
885 return 0;
886
887error:
888 // L10N: %s is the method name, e.g. Anonymous, CRAM-MD5, GSSAPI, SASL
889 mutt_error(_("%s authentication failed"), "LOGIN");
890 return -1;
891}
size_t mutt_b64_encode(const char *in, size_t inlen, char *out, size_t outlen)
Convert raw bytes to null-terminated base64 string.
Definition: base64.c:88
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:807
int mutt_socket_readln_d(char *buf, size_t buflen, struct Connection *conn, int dbg)
Read a line from a socket.
Definition: socket.c:250
+ Here is the call graph for this function:

◆ smtp_auth_is_valid()

bool smtp_auth_is_valid ( const char *  authenticator)

Check if string is a valid smtp authentication method.

Parameters
authenticatorAuthenticator string to check
Return values
trueArgument is a valid auth method

Validate whether an input string is an accepted smtp authentication method as defined by SmtpAuthenticators.

Definition at line 919 of file smtp.c.

920{
921 for (size_t i = 0; i < mutt_array_size(SmtpAuthenticators); i++)
922 {
923 const struct SmtpAuth *auth = &SmtpAuthenticators[i];
924 if (auth->method && mutt_istr_equal(auth->method, authenticator))
925 return true;
926 }
927
928 return false;
929}
#define mutt_array_size(x)
Definition: memory.h:36
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:819
static const struct SmtpAuth SmtpAuthenticators[]
Accepted authentication methods.
Definition: smtp.c:896
SMTP authentication multiplexor.
Definition: smtp.c:107
const char * method
Name of authentication method supported, NULL means variable.
Definition: smtp.c:116
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ smtp_authenticate()

static int smtp_authenticate ( struct SmtpAccountData adata)
static

Authenticate to an SMTP server.

Parameters
adataSMTP Account data
Return values
0Success
<0Error, e.g. SMTP_AUTH_FAIL

Definition at line 937 of file smtp.c.

938{
939 int r = SMTP_AUTH_UNAVAIL;
940
941 const struct Slist *c_smtp_authenticators = cs_subset_slist(adata->sub, "smtp_authenticators");
942 if (c_smtp_authenticators && (c_smtp_authenticators->count > 0))
943 {
944 mutt_debug(LL_DEBUG2, "Trying user-defined smtp_authenticators\n");
945
946 /* Try user-specified list of authentication methods */
947 struct ListNode *np = NULL;
948 STAILQ_FOREACH(np, &c_smtp_authenticators->head, entries)
949 {
950 mutt_debug(LL_DEBUG2, "Trying method %s\n", np->data);
951
952 for (size_t i = 0; i < mutt_array_size(SmtpAuthenticators); i++)
953 {
954 const struct SmtpAuth *auth = &SmtpAuthenticators[i];
955 if (!auth->method || mutt_istr_equal(auth->method, np->data))
956 {
957 r = auth->authenticate(adata, np->data);
958 if (r == SMTP_AUTH_SUCCESS)
959 return r;
960 }
961 }
962 }
963 }
964 else
965 {
966 /* Fall back to default: any authenticator */
967#if defined(USE_SASL_CYRUS)
968 mutt_debug(LL_DEBUG2, "Falling back to smtp_auth_sasl, if using sasl.\n");
969 r = smtp_auth_sasl(adata, adata->auth_mechs);
970#elif defined(USE_SASL_GNU)
971 mutt_debug(LL_DEBUG2, "Falling back to smtp_auth_gsasl, if using gsasl.\n");
972 r = smtp_auth_gsasl(adata, adata->auth_mechs);
973#else
974 mutt_debug(LL_DEBUG2, "Falling back to using any authenticator available.\n");
975 /* Try all available authentication methods */
976 for (size_t i = 0; i < mutt_array_size(SmtpAuthenticators); i++)
977 {
978 const struct SmtpAuth *auth = &SmtpAuthenticators[i];
979 mutt_debug(LL_DEBUG2, "Trying method %s\n", auth->method ? auth->method : "<variable>");
980 r = auth->authenticate(adata, auth->method);
981 if (r == SMTP_AUTH_SUCCESS)
982 return r;
983 }
984#endif
985 }
986
987 if (r != SMTP_AUTH_SUCCESS)
989
990 if (r == SMTP_AUTH_FAIL)
991 {
992 // L10N: %s is the method name, e.g. Anonymous, CRAM-MD5, GSSAPI, SASL
993 mutt_error(_("%s authentication failed"), "SASL");
994 }
995 else if (r == SMTP_AUTH_UNAVAIL)
996 {
997 mutt_error(_("No authenticators available"));
998 }
999
1000 return (r == SMTP_AUTH_SUCCESS) ? 0 : -1;
1001}
const struct Slist * cs_subset_slist(const struct ConfigSubset *sub, const char *name)
Get a string-list config item by name.
Definition: helpers.c:268
void mutt_account_unsetpass(struct ConnAccount *cac)
Unset ConnAccount's password.
Definition: connaccount.c:176
@ LL_DEBUG2
Log at debug level 2.
Definition: logging.h:41
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:352
#define SMTP_AUTH_UNAVAIL
Definition: smtp.c:73
A List node for strings.
Definition: list.h:35
char * data
String.
Definition: list.h:36
String list.
Definition: slist.h:47
struct ListHead head
List containing values.
Definition: slist.h:48
size_t count
Number of values in list.
Definition: slist.h:49
int(* authenticate)(struct SmtpAccountData *adata, const char *method)
Authenticate an SMTP connection.
Definition: smtp.c:114
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ smtp_open()

static int smtp_open ( struct SmtpAccountData adata,
bool  esmtp 
)
static

Open an SMTP Connection.

Parameters
adataSMTP Account data
esmtpIf true, use ESMTP
Return values
0Success
-1Error

Definition at line 1010 of file smtp.c.

1011{
1012 int rc;
1013
1014 if (mutt_socket_open(adata->conn))
1015 return -1;
1016
1017 const bool force_auth = cs_subset_string(adata->sub, "smtp_user");
1018 esmtp |= force_auth;
1019
1020 /* get greeting string */
1021 rc = smtp_get_resp(adata);
1022 if (rc != 0)
1023 return rc;
1024
1025 rc = smtp_helo(adata, esmtp);
1026 if (rc != 0)
1027 return rc;
1028
1029#ifdef USE_SSL
1030 const bool c_ssl_force_tls = cs_subset_bool(adata->sub, "ssl_force_tls");
1031 const enum QuadOption c_ssl_starttls = cs_subset_quad(adata->sub, "ssl_starttls");
1032 enum QuadOption ans = MUTT_NO;
1033 if (adata->conn->ssf != 0)
1034 ans = MUTT_NO;
1035 else if (c_ssl_force_tls)
1036 ans = MUTT_YES;
1037 else if ((adata->capabilities & SMTP_CAP_STARTTLS) &&
1038 ((ans = query_quadoption(c_ssl_starttls, _("Secure connection with TLS?"))) == MUTT_ABORT))
1039 {
1040 return -1;
1041 }
1042
1043 if (ans == MUTT_YES)
1044 {
1045 if (mutt_socket_send(adata->conn, "STARTTLS\r\n") < 0)
1046 return SMTP_ERR_WRITE;
1047 rc = smtp_get_resp(adata);
1048 // Clear any data after the STARTTLS acknowledgement
1049 mutt_socket_empty(adata->conn);
1050 if (rc != 0)
1051 return rc;
1052
1053 if (mutt_ssl_starttls(adata->conn))
1054 {
1055 mutt_error(_("Could not negotiate TLS connection"));
1056 return -1;
1057 }
1058
1059 /* re-EHLO to get authentication mechanisms */
1060 rc = smtp_helo(adata, esmtp);
1061 if (rc != 0)
1062 return rc;
1063 }
1064#endif
1065
1066 if (force_auth || adata->conn->account.flags & MUTT_ACCT_USER)
1067 {
1068 if (!(adata->capabilities & SMTP_CAP_AUTH))
1069 {
1070 mutt_error(_("SMTP server does not support authentication"));
1071 return -1;
1072 }
1073
1074 return smtp_authenticate(adata);
1075 }
1076
1077 return 0;
1078}
int mutt_ssl_starttls(struct Connection *conn)
Negotiate TLS over an already opened connection.
Definition: gnutls.c:1143
@ MUTT_ABORT
User aborted the question (with Ctrl-G)
Definition: quad.h:37
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
Definition: quad.h:39
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
Definition: question.c:386
static int smtp_authenticate(struct SmtpAccountData *adata)
Authenticate to an SMTP server.
Definition: smtp.c:937
static int smtp_helo(struct SmtpAccountData *adata, bool esmtp)
Say hello to an SMTP Server.
Definition: smtp.c:396
void mutt_socket_empty(struct Connection *conn)
Clear out any queued data.
Definition: socket.c:317
int mutt_socket_open(struct Connection *conn)
Simple wrapper.
Definition: socket.c:77
unsigned int ssf
Security strength factor, in bits (see notes)
Definition: connection.h:51
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_smtp_send()

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.

Parameters
fromFrom Address
toTo Address
ccCc Address
bccBcc Address
msgfileMessage to send to the server
eightbitIf true, try for an 8-bit friendly connection
subConfig Subset
Return values
0Success
-1Error

Definition at line 1092 of file smtp.c.

1095{
1096 struct SmtpAccountData adata = { 0 };
1097 struct ConnAccount cac = { { 0 } };
1098 const char *envfrom = NULL;
1099 char buf[1024] = { 0 };
1100 int rc = -1;
1101
1102 adata.sub = sub;
1103 adata.fqdn = mutt_fqdn(false, adata.sub);
1104 if (!adata.fqdn)
1105 adata.fqdn = NONULL(ShortHostname);
1106
1107 const struct Address *c_envelope_from_address = cs_subset_address(adata.sub, "envelope_from_address");
1108
1109 /* it might be better to synthesize an envelope from from user and host
1110 * but this condition is most likely arrived at accidentally */
1111 if (c_envelope_from_address)
1112 envfrom = c_envelope_from_address->mailbox;
1113 else if (from && !TAILQ_EMPTY(from))
1114 envfrom = TAILQ_FIRST(from)->mailbox;
1115 else
1116 {
1117 mutt_error(_("No from address given"));
1118 return -1;
1119 }
1120
1121 if (smtp_fill_account(&adata, &cac) < 0)
1122 return rc;
1123
1124 adata.conn = mutt_conn_find(&cac);
1125 if (!adata.conn)
1126 return -1;
1127
1128 const char *const c_dsn_return = cs_subset_string(adata.sub, "dsn_return");
1129
1130 do
1131 {
1132 /* send our greeting */
1133 rc = smtp_open(&adata, eightbit);
1134 if (rc != 0)
1135 break;
1136 FREE(&adata.auth_mechs);
1137
1138 /* send the sender's address */
1139 int len = snprintf(buf, sizeof(buf), "MAIL FROM:<%s>", envfrom);
1140 if (eightbit && (adata.capabilities & SMTP_CAP_EIGHTBITMIME))
1141 {
1142 mutt_strn_cat(buf, sizeof(buf), " BODY=8BITMIME", 15);
1143 len += 14;
1144 }
1145 if (c_dsn_return && (adata.capabilities & SMTP_CAP_DSN))
1146 len += snprintf(buf + len, sizeof(buf) - len, " RET=%s", c_dsn_return);
1147 if ((adata.capabilities & SMTP_CAP_SMTPUTF8) &&
1150 {
1151 snprintf(buf + len, sizeof(buf) - len, " SMTPUTF8");
1152 }
1153 mutt_strn_cat(buf, sizeof(buf), "\r\n", 3);
1154 if (mutt_socket_send(adata.conn, buf) == -1)
1155 {
1156 rc = SMTP_ERR_WRITE;
1157 break;
1158 }
1159 rc = smtp_get_resp(&adata);
1160 if (rc != 0)
1161 break;
1162
1163 /* send the recipient list */
1164 if ((rc = smtp_rcpt_to(&adata, to)) || (rc = smtp_rcpt_to(&adata, cc)) ||
1165 (rc = smtp_rcpt_to(&adata, bcc)))
1166 {
1167 break;
1168 }
1169
1170 /* send the message data */
1171 rc = smtp_data(&adata, msgfile);
1172 if (rc != 0)
1173 break;
1174
1175 mutt_socket_send(adata.conn, "QUIT\r\n");
1176
1177 rc = 0;
1178 } while (false);
1179
1180 mutt_socket_close(adata.conn);
1181 FREE(&adata.conn);
1182
1183 if (rc == SMTP_ERR_READ)
1184 mutt_error(_("SMTP session failed: read error"));
1185 else if (rc == SMTP_ERR_WRITE)
1186 mutt_error(_("SMTP session failed: write error"));
1187 else if (rc == SMTP_ERR_CODE)
1188 mutt_error(_("Invalid server response"));
1189
1190 return rc;
1191}
bool mutt_addrlist_uses_unicode(const struct AddressList *al)
Do any of a list of addresses use Unicode characters.
Definition: address.c:1497
bool mutt_addr_uses_unicode(const char *str)
Does this address use Unicode character.
Definition: address.c:1477
const struct Address * cs_subset_address(const struct ConfigSubset *sub, const char *name)
Get an Address config item by name.
Definition: helpers.c:49
char * ShortHostname
Short version of the hostname.
Definition: globals.c:39
char * mutt_strn_cat(char *d, size_t l, const char *s, size_t sl)
Concatenate two strings.
Definition: string.c:294
struct Connection * mutt_conn_find(const struct ConnAccount *cac)
Find a connection from a list.
Definition: mutt_socket.c:89
#define TAILQ_FIRST(head)
Definition: queue.h:723
#define TAILQ_EMPTY(head)
Definition: queue.h:721
const char * mutt_fqdn(bool may_hide_host, const struct ConfigSubset *sub)
Get the Fully-Qualified Domain Name.
Definition: sendlib.c:696
static int smtp_data(struct SmtpAccountData *adata, const char *msgfile)
Send data to an SMTP server.
Definition: smtp.c:225
static int smtp_fill_account(struct SmtpAccountData *adata, struct ConnAccount *cac)
Create ConnAccount object from SMTP Url.
Definition: smtp.c:342
static int smtp_rcpt_to(struct SmtpAccountData *adata, const struct AddressList *al)
Set the recipient to an Address.
Definition: smtp.c:188
static int smtp_open(struct SmtpAccountData *adata, bool esmtp)
Open an SMTP Connection.
Definition: smtp.c:1010
int mutt_socket_close(struct Connection *conn)
Close a socket.
Definition: socket.c:101
#define NONULL(x)
Definition: string2.h:37
Login details for a remote server.
Definition: connaccount.h:53
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ SmtpAuthenticators

const struct SmtpAuth SmtpAuthenticators[]
static
Initial value:
= {
{ smtp_auth_oauth, "oauthbearer" },
{ smtp_auth_xoauth2, "xoauth2" },
{ smtp_auth_plain, "plain" },
{ smtp_auth_login, "login" },
}
static int smtp_auth_xoauth2(struct SmtpAccountData *adata, const char *method)
Authenticate an SMTP connection using XOAUTH2.
Definition: smtp.c:767
static int smtp_auth_login(struct SmtpAccountData *adata, const char *method)
Authenticate using plain text.
Definition: smtp.c:826
static int smtp_auth_plain(struct SmtpAccountData *adata, const char *method)
Authenticate using plain text.
Definition: smtp.c:779
static int smtp_auth_oauth(struct SmtpAccountData *adata, const char *method)
Authenticate an SMTP connection using OAUTHBEARER.
Definition: smtp.c:756

Accepted authentication methods.

Definition at line 896 of file smtp.c.