NeoMutt  2021-02-05-89-gabe350
Teaching an old dog new tricks
DOXYGEN
smtp.c File Reference
#include "config.h"
#include <netdb.h>
#include <netinet/in.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.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 "gui/lib.h"
#include "smtp.h"
#include "send/lib.h"
#include "mutt_account.h"
#include "mutt_globals.h"
#include "mutt_socket.h"
#include "progress.h"
#include <sasl/sasl.h>
#include <sasl/saslutil.h>
#include "options.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_sasl (struct SmtpAccountData *adata, const char *mechlist)
 Authenticate using SASL. More...
 
static int smtp_auth_oauth (struct SmtpAccountData *adata, const char *method)
 Authenticate an SMTP connection using OAUTHBEARER. 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 smtp_authenticators []
 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 60 of file smtp.c.

◆ SMTP_READY

#define SMTP_READY   334

Definition at line 61 of file smtp.c.

◆ SMTP_CONTINUE

#define SMTP_CONTINUE   354

Definition at line 62 of file smtp.c.

◆ SMTP_ERR_READ

#define SMTP_ERR_READ   -2

Definition at line 64 of file smtp.c.

◆ SMTP_ERR_WRITE

#define SMTP_ERR_WRITE   -3

Definition at line 65 of file smtp.c.

◆ SMTP_ERR_CODE

#define SMTP_ERR_CODE   -4

Definition at line 66 of file smtp.c.

◆ SMTP_PORT

#define SMTP_PORT   25

Definition at line 68 of file smtp.c.

◆ SMTPS_PORT

#define SMTPS_PORT   465

Definition at line 69 of file smtp.c.

◆ SMTP_AUTH_SUCCESS

#define SMTP_AUTH_SUCCESS   0

Definition at line 71 of file smtp.c.

◆ SMTP_AUTH_UNAVAIL

#define SMTP_AUTH_UNAVAIL   1

Definition at line 72 of file smtp.c.

◆ SMTP_AUTH_FAIL

#define SMTP_AUTH_FAIL   -1

Definition at line 73 of file smtp.c.

◆ SMTP_CAP_NO_FLAGS

#define SMTP_CAP_NO_FLAGS   0

No flags are set.

Definition at line 80 of file smtp.c.

◆ SMTP_CAP_STARTTLS

#define SMTP_CAP_STARTTLS   (1 << 0)

Server supports STARTTLS command.

Definition at line 81 of file smtp.c.

◆ SMTP_CAP_AUTH

#define SMTP_CAP_AUTH   (1 << 1)

Server supports AUTH command.

Definition at line 82 of file smtp.c.

◆ SMTP_CAP_DSN

#define SMTP_CAP_DSN   (1 << 2)

Server supports Delivery Status Notification.

Definition at line 83 of file smtp.c.

◆ SMTP_CAP_EIGHTBITMIME

#define SMTP_CAP_EIGHTBITMIME   (1 << 3)

Server supports 8-bit MIME content.

Definition at line 84 of file smtp.c.

◆ SMTP_CAP_SMTPUTF8

#define SMTP_CAP_SMTPUTF8   (1 << 4)

Server accepts UTF-8 strings.

Definition at line 85 of file smtp.c.

◆ SMTP_CAP_ALL

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

Definition at line 87 of file smtp.c.

Typedef Documentation

◆ SmtpCapFlags

typedef uint8_t SmtpCapFlags

SMTP server capabilities.

Flags, e.g. SMTP_CAP_STARTTLS

Definition at line 79 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 126 of file smtp.c.

127 {
128  char code[4];
129 
130  if (buflen < 4)
131  return false;
132  code[0] = buf[0];
133  code[1] = buf[1];
134  code[2] = buf[2];
135  code[3] = '\0';
136  if (mutt_str_atoi(code, n) < 0)
137  return false;
138  return true;
139 }
+ 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 147 of file smtp.c.

148 {
149  int n;
150  char buf[1024];
151 
152  do
153  {
154  n = mutt_socket_readln(buf, sizeof(buf), adata->conn);
155  if (n < 4)
156  {
157  /* read error, or no response code */
158  return SMTP_ERR_READ;
159  }
160  const char *s = buf + 4; /* Skip the response code and the space/dash */
161  size_t plen;
162 
163  if (mutt_istr_startswith(s, "8BITMIME"))
165  else if ((plen = mutt_istr_startswith(s, "AUTH ")))
166  {
167  adata->capabilities |= SMTP_CAP_AUTH;
168  FREE(&adata->auth_mechs);
169  adata->auth_mechs = mutt_str_dup(s + plen);
170  }
171  else if (mutt_istr_startswith(s, "DSN"))
172  adata->capabilities |= SMTP_CAP_DSN;
173  else if (mutt_istr_startswith(s, "STARTTLS"))
175  else if (mutt_istr_startswith(s, "SMTPUTF8"))
177 
178  if (!valid_smtp_code(buf, n, &n))
179  return SMTP_ERR_CODE;
180 
181  } while (buf[3] == '-');
182 
183  if (smtp_success(n) || (n == SMTP_CONTINUE))
184  return 0;
185 
186  mutt_error(_("SMTP session failed: %s"), buf);
187  return -1;
188 }
+ 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 197 of file smtp.c.

198 {
199  if (!al)
200  return 0;
201 
202  const char *c_dsn_notify = cs_subset_string(adata->sub, "dsn_notify");
203 
204  struct Address *a = NULL;
205  TAILQ_FOREACH(a, al, entries)
206  {
207  /* weed out group mailboxes, since those are for display only */
208  if (!a->mailbox || a->group)
209  {
210  continue;
211  }
212  char buf[1024];
213  if ((adata->capabilities & SMTP_CAP_DSN) && c_dsn_notify)
214  snprintf(buf, sizeof(buf), "RCPT TO:<%s> NOTIFY=%s\r\n", a->mailbox, c_dsn_notify);
215  else
216  snprintf(buf, sizeof(buf), "RCPT TO:<%s>\r\n", a->mailbox);
217  if (mutt_socket_send(adata->conn, buf) == -1)
218  return SMTP_ERR_WRITE;
219  int rc = smtp_get_resp(adata);
220  if (rc != 0)
221  return rc;
222  }
223 
224  return 0;
225 }
+ 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 234 of file smtp.c.

235 {
236  char buf[1024];
237  struct Progress progress;
238  struct stat st;
239  int rc, term = 0;
240  size_t buflen = 0;
241 
242  FILE *fp = fopen(msgfile, "r");
243  if (!fp)
244  {
245  mutt_error(_("SMTP session failed: unable to open %s"), msgfile);
246  return -1;
247  }
248  stat(msgfile, &st);
249  unlink(msgfile);
250  mutt_progress_init(&progress, _("Sending message..."), MUTT_PROGRESS_NET, st.st_size);
251 
252  snprintf(buf, sizeof(buf), "DATA\r\n");
253  if (mutt_socket_send(adata->conn, buf) == -1)
254  {
255  mutt_file_fclose(&fp);
256  return SMTP_ERR_WRITE;
257  }
258  rc = smtp_get_resp(adata);
259  if (rc != 0)
260  {
261  mutt_file_fclose(&fp);
262  return rc;
263  }
264 
265  while (fgets(buf, sizeof(buf) - 1, fp))
266  {
267  buflen = mutt_str_len(buf);
268  term = buflen && buf[buflen - 1] == '\n';
269  if (term && ((buflen == 1) || (buf[buflen - 2] != '\r')))
270  snprintf(buf + buflen - 1, sizeof(buf) - buflen + 1, "\r\n");
271  if (buf[0] == '.')
272  {
273  if (mutt_socket_send_d(adata->conn, ".", MUTT_SOCK_LOG_FULL) == -1)
274  {
275  mutt_file_fclose(&fp);
276  return SMTP_ERR_WRITE;
277  }
278  }
279  if (mutt_socket_send_d(adata->conn, buf, MUTT_SOCK_LOG_FULL) == -1)
280  {
281  mutt_file_fclose(&fp);
282  return SMTP_ERR_WRITE;
283  }
284  mutt_progress_update(&progress, ftell(fp), -1);
285  }
286  if (!term && buflen &&
287  (mutt_socket_send_d(adata->conn, "\r\n", MUTT_SOCK_LOG_FULL) == -1))
288  {
289  mutt_file_fclose(&fp);
290  return SMTP_ERR_WRITE;
291  }
292  mutt_file_fclose(&fp);
293 
294  /* terminate the message body */
295  if (mutt_socket_send(adata->conn, ".\r\n") == -1)
296  return SMTP_ERR_WRITE;
297 
298  rc = smtp_get_resp(adata);
299  if (rc != 0)
300  return rc;
301 
302  return 0;
303 }
+ 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 308 of file smtp.c.

309 {
310  struct SmtpAccountData *adata = gf_data;
311  if (!adata)
312  return NULL;
313 
314  switch (field)
315  {
316  case MUTT_CA_LOGIN:
317  case MUTT_CA_USER:
318  {
319  const char *c_smtp_user = cs_subset_string(adata->sub, "smtp_user");
320  return c_smtp_user;
321  }
322  case MUTT_CA_PASS:
323  {
324  const char *c_smtp_pass = cs_subset_string(adata->sub, "smtp_pass");
325  return c_smtp_pass;
326  }
327  case MUTT_CA_OAUTH_CMD:
328  {
329  const char *c_smtp_oauth_refresh_command =
330  cs_subset_string(adata->sub, "smtp_oauth_refresh_command");
331  return c_smtp_oauth_refresh_command;
332  }
333  case MUTT_CA_HOST:
334  default:
335  return NULL;
336  }
337 }
+ 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 346 of file smtp.c.

347 {
348  cac->flags = 0;
349  cac->port = 0;
350  cac->type = MUTT_ACCT_TYPE_SMTP;
351  cac->service = "smtp";
352  cac->get_field = smtp_get_field;
353  cac->gf_data = adata;
354 
355  const char *c_smtp_url = cs_subset_string(adata->sub, "smtp_url");
356 
357  struct Url *url = url_parse(c_smtp_url);
358  if (!url || ((url->scheme != U_SMTP) && (url->scheme != U_SMTPS)) ||
359  !url->host || (mutt_account_fromurl(cac, url) < 0))
360  {
361  url_free(&url);
362  mutt_error(_("Invalid SMTP URL: %s"), c_smtp_url);
363  return -1;
364  }
365 
366  if (url->scheme == U_SMTPS)
367  cac->flags |= MUTT_ACCT_SSL;
368 
369  if (cac->port == 0)
370  {
371  if (cac->flags & MUTT_ACCT_SSL)
372  cac->port = SMTPS_PORT;
373  else
374  {
375  static unsigned short SmtpPort = 0;
376  if (SmtpPort == 0)
377  {
378  struct servent *service = getservbyname("smtp", "tcp");
379  if (service)
380  SmtpPort = ntohs(service->s_port);
381  else
382  SmtpPort = SMTP_PORT;
383  mutt_debug(LL_DEBUG3, "Using default SMTP port %d\n", SmtpPort);
384  }
385  cac->port = SmtpPort;
386  }
387  }
388 
389  url_free(&url);
390  return 0;
391 }
+ 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 400 of file smtp.c.

401 {
403 
404  if (!esmtp)
405  {
406  /* if TLS or AUTH are requested, use EHLO */
407  if (adata->conn->account.flags & MUTT_ACCT_USER)
408  esmtp = true;
409 #ifdef USE_SSL
410  const bool c_ssl_force_tls = cs_subset_bool(adata->sub, "ssl_force_tls");
411  const enum QuadOption c_ssl_starttls =
412  cs_subset_quad(adata->sub, "ssl_starttls");
413 
414  if (c_ssl_force_tls || (c_ssl_starttls != MUTT_NO))
415  esmtp = true;
416 #endif
417  }
418 
419  char buf[1024];
420  snprintf(buf, sizeof(buf), "%s %s\r\n", esmtp ? "EHLO" : "HELO", adata->fqdn);
421  /* XXX there should probably be a wrapper in mutt_socket.c that
422  * repeatedly calls adata->conn->write until all data is sent. This
423  * currently doesn't check for a short write. */
424  if (mutt_socket_send(adata->conn, buf) == -1)
425  return SMTP_ERR_WRITE;
426  return smtp_get_resp(adata);
427 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ smtp_auth_sasl()

static int smtp_auth_sasl ( struct SmtpAccountData adata,
const char *  mechlist 
)
static

Authenticate using SASL.

Parameters
adataSMTP Account data
mechlistList of mechanisms to use
Return values
0Success
<0Error, e.g. SMTP_AUTH_FAIL

Definition at line 437 of file smtp.c.

438 {
439  sasl_conn_t *saslconn = NULL;
440  sasl_interact_t *interaction = NULL;
441  const char *mech = NULL;
442  const char *data = NULL;
443  unsigned int len;
444  char *buf = NULL;
445  size_t bufsize = 0;
446  int rc, saslrc;
447 
448  if (mutt_sasl_client_new(adata->conn, &saslconn) < 0)
449  return SMTP_AUTH_FAIL;
450 
451  do
452  {
453  rc = sasl_client_start(saslconn, mechlist, &interaction, &data, &len, &mech);
454  if (rc == SASL_INTERACT)
455  mutt_sasl_interact(interaction);
456  } while (rc == SASL_INTERACT);
457 
458  if ((rc != SASL_OK) && (rc != SASL_CONTINUE))
459  {
460  mutt_debug(LL_DEBUG2, "%s unavailable\n", NONULL(mech));
461  sasl_dispose(&saslconn);
462  return SMTP_AUTH_UNAVAIL;
463  }
464 
465  if (!OptNoCurses)
466  {
467  // L10N: (%s) is the method name, e.g. Anonymous, CRAM-MD5, GSSAPI, SASL
468  mutt_message(_("Authenticating (%s)..."), mech);
469  }
470 
471  bufsize = MAX((len * 2), 1024);
472  buf = mutt_mem_malloc(bufsize);
473 
474  snprintf(buf, bufsize, "AUTH %s", mech);
475  if (len)
476  {
477  mutt_str_cat(buf, bufsize, " ");
478  if (sasl_encode64(data, len, buf + mutt_str_len(buf),
479  bufsize - mutt_str_len(buf), &len) != SASL_OK)
480  {
481  mutt_debug(LL_DEBUG1, "#1 error base64-encoding client response\n");
482  goto fail;
483  }
484  }
485  mutt_str_cat(buf, bufsize, "\r\n");
486 
487  do
488  {
489  if (mutt_socket_send(adata->conn, buf) < 0)
490  goto fail;
491  rc = mutt_socket_readln_d(buf, bufsize, adata->conn, MUTT_SOCK_LOG_FULL);
492  if (rc < 0)
493  goto fail;
494  if (!valid_smtp_code(buf, rc, &rc))
495  goto fail;
496 
497  if (rc != SMTP_READY)
498  break;
499 
500  if (sasl_decode64(buf + 4, strlen(buf + 4), buf, bufsize - 1, &len) != SASL_OK)
501  {
502  mutt_debug(LL_DEBUG1, "error base64-decoding server response\n");
503  goto fail;
504  }
505 
506  do
507  {
508  saslrc = sasl_client_step(saslconn, buf, len, &interaction, &data, &len);
509  if (saslrc == SASL_INTERACT)
510  mutt_sasl_interact(interaction);
511  } while (saslrc == SASL_INTERACT);
512 
513  if (len)
514  {
515  if ((len * 2) > bufsize)
516  {
517  bufsize = len * 2;
518  mutt_mem_realloc(&buf, bufsize);
519  }
520  if (sasl_encode64(data, len, buf, bufsize, &len) != SASL_OK)
521  {
522  mutt_debug(LL_DEBUG1, "#2 error base64-encoding client response\n");
523  goto fail;
524  }
525  }
526  mutt_str_copy(buf + len, "\r\n", bufsize - len);
527  } while (rc == SMTP_READY && saslrc != SASL_FAIL);
528 
529  if (smtp_success(rc))
530  {
531  mutt_sasl_setup_conn(adata->conn, saslconn);
532  FREE(&buf);
533  return SMTP_AUTH_SUCCESS;
534  }
535 
536 fail:
537  sasl_dispose(&saslconn);
538  FREE(&buf);
539  return SMTP_AUTH_FAIL;
540 }
+ 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 549 of file smtp.c.

550 {
551  (void) method; // This is OAUTHBEARER
552 
553  // L10N: (%s) is the method name, e.g. Anonymous, CRAM-MD5, GSSAPI, SASL
554  mutt_message(_("Authenticating (%s)..."), "OAUTHBEARER");
555 
556  /* We get the access token from the smtp_oauth_refresh_command */
557  char *oauthbearer = mutt_account_getoauthbearer(&adata->conn->account);
558  if (!oauthbearer)
559  return SMTP_AUTH_FAIL;
560 
561  size_t ilen = strlen(oauthbearer) + 30;
562  char *ibuf = mutt_mem_malloc(ilen);
563  snprintf(ibuf, ilen, "AUTH OAUTHBEARER %s\r\n", oauthbearer);
564 
565  int rc = mutt_socket_send(adata->conn, ibuf);
566  FREE(&oauthbearer);
567  FREE(&ibuf);
568 
569  if (rc == -1)
570  return SMTP_AUTH_FAIL;
571  if (smtp_get_resp(adata) != 0)
572  return SMTP_AUTH_FAIL;
573 
574  return SMTP_AUTH_SUCCESS;
575 }
+ 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 584 of file smtp.c.

585 {
586  (void) method; // This is PLAIN
587 
588  char buf[1024];
589 
590  /* Get username and password. Bail out of any can't be retrieved. */
591  if ((mutt_account_getuser(&adata->conn->account) < 0) ||
592  (mutt_account_getpass(&adata->conn->account) < 0))
593  {
594  goto error;
595  }
596 
597  /* Build the initial client response. */
598  size_t len =
599  mutt_sasl_plain_msg(buf, sizeof(buf), "AUTH PLAIN", adata->conn->account.user,
600  adata->conn->account.user, adata->conn->account.pass);
601 
602  /* Terminate as per SMTP protocol. Bail out if there's no room left. */
603  if (snprintf(buf + len, sizeof(buf) - len, "\r\n") != 2)
604  {
605  goto error;
606  }
607 
608  /* Send request, receive response (with a check for OK code). */
609  if ((mutt_socket_send(adata->conn, buf) < 0) || smtp_get_resp(adata))
610  {
611  goto error;
612  }
613 
614  /* If we got here, auth was successful. */
615  return 0;
616 
617 error:
618  // L10N: %s is the method name, e.g. Anonymous, CRAM-MD5, GSSAPI, SASL
619  mutt_error(_("%s authentication failed"), "SASL");
620  return -1;
621 }
+ 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 630 of file smtp.c.

631 {
632  (void) method; // This is LOGIN
633 
634  char b64[1024] = { 0 };
635  char buf[1024] = { 0 };
636 
637  /* Get username and password. Bail out of any can't be retrieved. */
638  if ((mutt_account_getuser(&adata->conn->account) < 0) ||
639  (mutt_account_getpass(&adata->conn->account) < 0))
640  {
641  goto error;
642  }
643 
644  /* Send the AUTH LOGIN request. */
645  if (mutt_socket_send(adata->conn, "AUTH LOGIN\r\n") < 0)
646  {
647  goto error;
648  }
649 
650  /* Read the 334 VXNlcm5hbWU6 challenge ("Username:" base64-encoded) */
651  mutt_socket_readln_d(buf, sizeof(buf), adata->conn, MUTT_SOCK_LOG_FULL);
652  if (!mutt_str_equal(buf, "334 VXNlcm5hbWU6"))
653  {
654  goto error;
655  }
656 
657  /* Send the username */
658  size_t len = snprintf(buf, sizeof(buf), "%s", adata->conn->account.user);
659  mutt_b64_encode(buf, len, b64, sizeof(b64));
660  snprintf(buf, sizeof(buf), "%s\r\n", b64);
661  if (mutt_socket_send(adata->conn, buf) < 0)
662  {
663  goto error;
664  }
665 
666  /* Read the 334 UGFzc3dvcmQ6 challenge ("Password:" base64-encoded) */
667  mutt_socket_readln_d(buf, sizeof(buf), adata->conn, MUTT_SOCK_LOG_FULL);
668  if (!mutt_str_equal(buf, "334 UGFzc3dvcmQ6"))
669  {
670  goto error;
671  }
672 
673  /* Send the password */
674  len = snprintf(buf, sizeof(buf), "%s", adata->conn->account.pass);
675  mutt_b64_encode(buf, len, b64, sizeof(b64));
676  snprintf(buf, sizeof(buf), "%s\r\n", b64);
677  if (mutt_socket_send(adata->conn, buf) < 0)
678  {
679  goto error;
680  }
681 
682  /* Check the final response */
683  if (smtp_get_resp(adata) < 0)
684  {
685  goto error;
686  }
687 
688  /* If we got here, auth was successful. */
689  return 0;
690 
691 error:
692  // L10N: %s is the method name, e.g. Anonymous, CRAM-MD5, GSSAPI, SASL
693  mutt_error(_("%s authentication failed"), "LOGIN");
694  return -1;
695 }
+ 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
boolTrue if argument is a valid auth method

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

Definition at line 717 of file smtp.c.

718 {
719  for (size_t i = 0; i < mutt_array_size(smtp_authenticators); i++)
720  {
721  const struct SmtpAuth *auth = &smtp_authenticators[i];
722  if (auth->method && mutt_istr_equal(auth->method, authenticator))
723  return true;
724  }
725 
726  return false;
727 }
+ 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 735 of file smtp.c.

736 {
737  int r = SMTP_AUTH_UNAVAIL;
738 
739  const struct Slist *c_smtp_authenticators =
740  cs_subset_slist(adata->sub, "smtp_authenticators");
741  if (c_smtp_authenticators && (c_smtp_authenticators->count > 0))
742  {
743  mutt_debug(LL_DEBUG2, "Trying user-defined smtp_authenticators\n");
744 
745  /* Try user-specified list of authentication methods */
746  struct ListNode *np = NULL;
747  STAILQ_FOREACH(np, &c_smtp_authenticators->head, entries)
748  {
749  mutt_debug(LL_DEBUG2, "Trying method %s\n", np->data);
750 
751  for (size_t i = 0; i < mutt_array_size(smtp_authenticators); i++)
752  {
753  const struct SmtpAuth *auth = &smtp_authenticators[i];
754  if (!auth->method || mutt_istr_equal(auth->method, np->data))
755  {
756  r = auth->authenticate(adata, np->data);
757  if (r == SMTP_AUTH_SUCCESS)
758  return r;
759  }
760  }
761  }
762  }
763  else
764  {
765  /* Fall back to default: any authenticator */
766  mutt_debug(LL_DEBUG2, "Falling back to smtp_auth_sasl, if using sasl.\n");
767 
768 #ifdef USE_SASL
769  r = smtp_auth_sasl(adata, adata->auth_mechs);
770 #else
771  mutt_error(_("SMTP authentication requires SASL"));
772  r = SMTP_AUTH_UNAVAIL;
773 #endif
774  }
775 
776  if (r != SMTP_AUTH_SUCCESS)
778 
779  if (r == SMTP_AUTH_FAIL)
780  {
781  // L10N: %s is the method name, e.g. Anonymous, CRAM-MD5, GSSAPI, SASL
782  mutt_error(_("%s authentication failed"), "SASL");
783  }
784  else if (r == SMTP_AUTH_UNAVAIL)
785  {
786  mutt_error(_("No authenticators available"));
787  }
788 
789  return (r == SMTP_AUTH_SUCCESS) ? 0 : -1;
790 }
+ 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 799 of file smtp.c.

800 {
801  int rc;
802 
803  if (mutt_socket_open(adata->conn))
804  return -1;
805 
806  /* get greeting string */
807  rc = smtp_get_resp(adata);
808  if (rc != 0)
809  return rc;
810 
811  rc = smtp_helo(adata, esmtp);
812  if (rc != 0)
813  return rc;
814 
815 #ifdef USE_SSL
816  const bool c_ssl_force_tls = cs_subset_bool(adata->sub, "ssl_force_tls");
817  const enum QuadOption c_ssl_starttls =
818  cs_subset_quad(adata->sub, "ssl_starttls");
819  enum QuadOption ans = MUTT_NO;
820  if (adata->conn->ssf != 0)
821  ans = MUTT_NO;
822  else if (c_ssl_force_tls)
823  ans = MUTT_YES;
824  else if ((adata->capabilities & SMTP_CAP_STARTTLS) &&
825  ((ans = query_quadoption(c_ssl_starttls,
826  _("Secure connection with TLS?"))) == MUTT_ABORT))
827  {
828  return -1;
829  }
830 
831  if (ans == MUTT_YES)
832  {
833  if (mutt_socket_send(adata->conn, "STARTTLS\r\n") < 0)
834  return SMTP_ERR_WRITE;
835  rc = smtp_get_resp(adata);
836  // Clear any data after the STARTTLS acknowledgement
837  mutt_socket_empty(adata->conn);
838  if (rc != 0)
839  return rc;
840 
841  if (mutt_ssl_starttls(adata->conn))
842  {
843  mutt_error(_("Could not negotiate TLS connection"));
844  return -1;
845  }
846 
847  /* re-EHLO to get authentication mechanisms */
848  rc = smtp_helo(adata, esmtp);
849  if (rc != 0)
850  return rc;
851  }
852 #endif
853 
854  if (adata->conn->account.flags & MUTT_ACCT_USER)
855  {
856  if (!(adata->capabilities & SMTP_CAP_AUTH))
857  {
858  mutt_error(_("SMTP server does not support authentication"));
859  return -1;
860  }
861 
862  return smtp_authenticate(adata);
863  }
864 
865  return 0;
866 }
+ 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 880 of file smtp.c.

883 {
884  struct SmtpAccountData adata = { 0 };
885  struct ConnAccount cac = { { 0 } };
886  const char *envfrom = NULL;
887  char buf[1024];
888  int rc = -1;
889 
890  adata.sub = sub;
891  adata.fqdn = mutt_fqdn(false, adata.sub);
892  if (!adata.fqdn)
893  adata.fqdn = NONULL(ShortHostname);
894 
895  const struct Address *c_envelope_from_address =
896  cs_subset_address(adata.sub, "envelope_from_address");
897 
898  /* it might be better to synthesize an envelope from from user and host
899  * but this condition is most likely arrived at accidentally */
900  if (c_envelope_from_address)
901  envfrom = c_envelope_from_address->mailbox;
902  else if (from && !TAILQ_EMPTY(from))
903  envfrom = TAILQ_FIRST(from)->mailbox;
904  else
905  {
906  mutt_error(_("No from address given"));
907  return -1;
908  }
909 
910  if (smtp_fill_account(&adata, &cac) < 0)
911  return rc;
912 
913  adata.conn = mutt_conn_find(&cac);
914  if (!adata.conn)
915  return -1;
916 
917  const char *c_dsn_return = cs_subset_string(adata.sub, "dsn_return");
918 
919  do
920  {
921  /* send our greeting */
922  rc = smtp_open(&adata, eightbit);
923  if (rc != 0)
924  break;
925  FREE(&adata.auth_mechs);
926 
927  /* send the sender's address */
928  int len = snprintf(buf, sizeof(buf), "MAIL FROM:<%s>", envfrom);
929  if (eightbit && (adata.capabilities & SMTP_CAP_EIGHTBITMIME))
930  {
931  mutt_strn_cat(buf, sizeof(buf), " BODY=8BITMIME", 15);
932  len += 14;
933  }
934  if (c_dsn_return && (adata.capabilities & SMTP_CAP_DSN))
935  len += snprintf(buf + len, sizeof(buf) - len, " RET=%s", c_dsn_return);
936  if ((adata.capabilities & SMTP_CAP_SMTPUTF8) &&
939  {
940  snprintf(buf + len, sizeof(buf) - len, " SMTPUTF8");
941  }
942  mutt_strn_cat(buf, sizeof(buf), "\r\n", 3);
943  if (mutt_socket_send(adata.conn, buf) == -1)
944  {
945  rc = SMTP_ERR_WRITE;
946  break;
947  }
948  rc = smtp_get_resp(&adata);
949  if (rc != 0)
950  break;
951 
952  /* send the recipient list */
953  if ((rc = smtp_rcpt_to(&adata, to)) || (rc = smtp_rcpt_to(&adata, cc)) ||
954  (rc = smtp_rcpt_to(&adata, bcc)))
955  {
956  break;
957  }
958 
959  /* send the message data */
960  rc = smtp_data(&adata, msgfile);
961  if (rc != 0)
962  break;
963 
964  mutt_socket_send(adata.conn, "QUIT\r\n");
965 
966  rc = 0;
967  } while (false);
968 
969  mutt_socket_close(adata.conn);
970  FREE(&adata.conn);
971 
972  if (rc == SMTP_ERR_READ)
973  mutt_error(_("SMTP session failed: read error"));
974  else if (rc == SMTP_ERR_WRITE)
975  mutt_error(_("SMTP session failed: write error"));
976  else if (rc == SMTP_ERR_CODE)
977  mutt_error(_("Invalid server response"));
978 
979  return rc;
980 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ smtp_authenticators

const struct SmtpAuth smtp_authenticators[]
static
Initial value:
= {
{ smtp_auth_oauth, "oauthbearer" },
{ smtp_auth_plain, "plain" },
{ smtp_auth_login, "login" },
{ smtp_auth_sasl, NULL },
}

Accepted authentication methods.

Definition at line 700 of file smtp.c.

SMTPS_PORT
#define SMTPS_PORT
Definition: smtp.c:69
MUTT_PROGRESS_NET
@ MUTT_PROGRESS_NET
Progress tracks bytes, according to $net_inc
Definition: progress.h:44
ConnAccount
Login details for a remote server.
Definition: connaccount.h:51
valid_smtp_code
static bool valid_smtp_code(char *buf, size_t buflen, int *n)
Is the is a valid SMTP return code?
Definition: smtp.c:126
QuadOption
QuadOption
Possible values for a quad-option.
Definition: quad.h:36
SmtpAccountData::fqdn
const char * fqdn
Fully-qualified domain name.
Definition: smtp.c:99
SmtpAccountData::auth_mechs
const char * auth_mechs
Allowed authorisation mechanisms.
Definition: smtp.c:95
mutt_sasl_client_new
int mutt_sasl_client_new(struct Connection *conn, sasl_conn_t **saslconn)
Wrapper for sasl_client_new()
Definition: sasl.c:603
MUTT_ACCT_TYPE_SMTP
@ MUTT_ACCT_TYPE_SMTP
Smtp Account.
Definition: mutt_account.h:39
mutt_account_fromurl
int mutt_account_fromurl(struct ConnAccount *cac, const struct Url *url)
Fill ConnAccount with information from url.
Definition: mutt_account.c:43
smtp_auth_oauth
static int smtp_auth_oauth(struct SmtpAccountData *adata, const char *method)
Authenticate an SMTP connection using OAUTHBEARER.
Definition: smtp.c:549
_
#define _(a)
Definition: message.h:28
NONULL
#define NONULL(x)
Definition: string2.h:37
SMTP_PORT
#define SMTP_PORT
Definition: smtp.c:68
SMTP_AUTH_UNAVAIL
#define SMTP_AUTH_UNAVAIL
Definition: smtp.c:72
ListNode
A List node for strings.
Definition: list.h:34
LL_DEBUG3
@ LL_DEBUG3
Log at debug level 3.
Definition: logging.h:42
Connection::account
struct ConnAccount account
Account details: username, password, etc.
Definition: connection.h:36
mutt_sasl_interact
int mutt_sasl_interact(sasl_interact_t *interaction)
Perform an SASL interaction with the user.
Definition: sasl.c:698
ConnAccount::get_field
const char *(* get_field)(enum ConnAccountField field, void *gf_data)
Function to get some login credentials.
Definition: connaccount.h:67
mutt_file_fclose
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:153
mutt_socket_empty
void mutt_socket_empty(struct Connection *conn)
Clear out any queued data.
Definition: socket.c:312
mutt_socket_readln_d
int mutt_socket_readln_d(char *buf, size_t buflen, struct Connection *conn, int dbg)
Read a line from a socket.
Definition: socket.c:245
Slist::head
struct ListHead head
Definition: slist.h:48
cs_subset_bool
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:69
SMTP_ERR_WRITE
#define SMTP_ERR_WRITE
Definition: smtp.c:65
TAILQ_EMPTY
#define TAILQ_EMPTY(head)
Definition: queue.h:714
TAILQ_FOREACH
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:718
mutt_socket_close
int mutt_socket_close(struct Connection *conn)
Close a socket.
Definition: socket.c:96
Url::scheme
enum UrlScheme scheme
Scheme, e.g. U_SMTPS.
Definition: url.h:69
SmtpAccountData
Server connection data.
Definition: smtp.c:93
mutt_sasl_plain_msg
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:56
MUTT_YES
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
Definition: quad.h:40
SMTP_AUTH_FAIL
#define SMTP_AUTH_FAIL
Definition: smtp.c:73
mutt_str_dup
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
LL_DEBUG1
@ LL_DEBUG1
Log at debug level 1.
Definition: logging.h:40
FREE
#define FREE(x)
Definition: memory.h:40
ConnAccount::gf_data
void * gf_data
Private data to pass to get_field()
Definition: connaccount.h:69
mutt_socket_readln
#define mutt_socket_readln(buf, buflen, conn)
Definition: mutt_socket.h:36
SmtpAuth
SMTP authentication multiplexor.
Definition: smtp.c:105
smtp_data
static int smtp_data(struct SmtpAccountData *adata, const char *msgfile)
Send data to an SMTP server.
Definition: smtp.c:234
SMTP_CAP_DSN
#define SMTP_CAP_DSN
Server supports Delivery Status Notification.
Definition: smtp.c:83
MUTT_ABORT
@ MUTT_ABORT
User aborted the question (with Ctrl-G)
Definition: quad.h:38
OptNoCurses
WHERE bool OptNoCurses
(pseudo) when sending in batch mode
Definition: options.h:48
SMTP_CAP_AUTH
#define SMTP_CAP_AUTH
Server supports AUTH command.
Definition: smtp.c:82
url_parse
struct Url * url_parse(const char *src)
Fill in Url.
Definition: url.c:234
mutt_array_size
#define mutt_array_size(x)
Definition: memory.h:33
mutt_str_atoi
int mutt_str_atoi(const char *str, int *dst)
Convert ASCII string to an integer.
Definition: string.c:252
STAILQ_FOREACH
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
SMTP_CAP_STARTTLS
#define SMTP_CAP_STARTTLS
Server supports STARTTLS command.
Definition: smtp.c:81
smtp_helo
static int smtp_helo(struct SmtpAccountData *adata, bool esmtp)
Say hello to an SMTP Server.
Definition: smtp.c:400
mutt_istr_equal
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:883
smtp_auth_login
static int smtp_auth_login(struct SmtpAccountData *adata, const char *method)
Authenticate using plain text.
Definition: smtp.c:630
mutt_str_equal
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
smtp_fill_account
static int smtp_fill_account(struct SmtpAccountData *adata, struct ConnAccount *cac)
Create ConnAccount object from SMTP Url.
Definition: smtp.c:346
mutt_strn_cat
char * mutt_strn_cat(char *d, size_t l, const char *s, size_t sl)
Concatenate two strings.
Definition: string.c:414
SMTP_CONTINUE
#define SMTP_CONTINUE
Definition: smtp.c:62
SMTP_CAP_EIGHTBITMIME
#define SMTP_CAP_EIGHTBITMIME
Server supports 8-bit MIME content.
Definition: smtp.c:84
mutt_progress_init
void mutt_progress_init(struct Progress *progress, const char *msg, enum ProgressType type, size_t size)
Set up a progress bar.
Definition: progress.c:153
TAILQ_FIRST
#define TAILQ_FIRST(head)
Definition: queue.h:716
mutt_sasl_setup_conn
void mutt_sasl_setup_conn(struct Connection *conn, sasl_conn_t *saslconn)
Set up an SASL connection.
Definition: sasl.c:734
cs_subset_address
const struct Address * cs_subset_address(const struct ConfigSubset *sub, const char *name)
Get an Address config item by name.
Definition: helpers.c:48
query_quadoption
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
Definition: curs_lib.c:518
U_SMTPS
@ U_SMTPS
Url is smtps://.
Definition: url.h:43
SmtpAuth::method
const char * method
Name of authentication method supported, NULL means variable.
Definition: smtp.c:115
mutt_account_unsetpass
void mutt_account_unsetpass(struct ConnAccount *cac)
Unset ConnAccount's password.
Definition: connaccount.c:141
SmtpAccountData::conn
struct Connection * conn
Server Connection.
Definition: smtp.c:97
smtp_authenticate
static int smtp_authenticate(struct SmtpAccountData *adata)
Authenticate to an SMTP server.
Definition: smtp.c:735
mutt_b64_encode
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
MUTT_CA_PASS
@ MUTT_CA_PASS
Password.
Definition: connaccount.h:36
Address::group
bool group
Group mailbox?
Definition: address.h:38
Progress
A progress bar.
Definition: progress.h:50
MUTT_CA_HOST
@ MUTT_CA_HOST
Server name.
Definition: connaccount.h:33
Url
A parsed URL proto://user:password@host:port/path?a=1&b=2
Definition: url.h:67
SmtpAccountData::sub
struct ConfigSubset * sub
Config scope.
Definition: smtp.c:98
url_free
void url_free(struct Url **ptr)
Free the contents of a URL.
Definition: url.c:123
SmtpAccountData::capabilities
SmtpCapFlags capabilities
Server capabilities.
Definition: smtp.c:96
MAX
#define MAX(a, b)
Definition: memory.h:30
SmtpAuth::authenticate
int(* authenticate)(struct SmtpAccountData *adata, const char *method)
Authenticate an SMTP connection.
Definition: smtp.c:113
U_SMTP
@ U_SMTP
Url is smtp://.
Definition: url.h:42
mutt_socket_send
#define mutt_socket_send(conn, buf)
Definition: mutt_socket.h:37
mutt_mem_realloc
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:114
SMTP_ERR_CODE
#define SMTP_ERR_CODE
Definition: smtp.c:66
smtp_open
static int smtp_open(struct SmtpAccountData *adata, bool esmtp)
Open an SMTP Connection.
Definition: smtp.c:799
ConnAccount::type
unsigned char type
Connection type, e.g. MUTT_ACCT_TYPE_IMAP.
Definition: connaccount.h:58
mutt_debug
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
MUTT_NO
@ MUTT_NO
User answered 'No', or assume 'No'.
Definition: quad.h:39
smtp_auth_plain
static int smtp_auth_plain(struct SmtpAccountData *adata, const char *method)
Authenticate using plain text.
Definition: smtp.c:584
mutt_str_len
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definition: string.c:631
MUTT_ACCT_USER
#define MUTT_ACCT_USER
User field has been set.
Definition: connaccount.h:43
ConnAccount::flags
MuttAccountFlags flags
Which fields are initialised, e.g. MUTT_ACCT_USER.
Definition: connaccount.h:59
cs_subset_quad
enum QuadOption cs_subset_quad(const struct ConfigSubset *sub, const char *name)
Get a quad-value config item by name.
Definition: helpers.c:154
SMTP_AUTH_SUCCESS
#define SMTP_AUTH_SUCCESS
Definition: smtp.c:71
smtp_authenticators
static const struct SmtpAuth smtp_authenticators[]
Accepted authentication methods.
Definition: smtp.c:700
Address::mailbox
char * mailbox
Mailbox and host address.
Definition: address.h:37
cs_subset_string
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:241
MUTT_CA_LOGIN
@ MUTT_CA_LOGIN
Login name.
Definition: connaccount.h:34
MUTT_ACCT_SSL
#define MUTT_ACCT_SSL
Account uses SSL/TLS.
Definition: connaccount.h:46
mutt_addrlist_uses_unicode
bool mutt_addrlist_uses_unicode(const struct AddressList *al)
Do any of a list of addresses use Unicode characters.
Definition: address.c:1530
mutt_str_cat
char * mutt_str_cat(char *buf, size_t buflen, const char *s)
Concatenate two strings.
Definition: string.c:385
Slist::count
size_t count
Definition: slist.h:49
mutt_socket_open
int mutt_socket_open(struct Connection *conn)
Simple wrapper.
Definition: socket.c:75
ConnAccount::port
unsigned short port
Port to connect to.
Definition: connaccount.h:57
mutt_mem_malloc
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Definition: memory.c:90
ShortHostname
WHERE char * ShortHostname
Short version of the hostname.
Definition: mutt_globals.h:50
smtp_get_field
static const char * smtp_get_field(enum ConnAccountField field, void *gf_data)
Get connection login credentials - Implements ConnAccount::get_field()
Definition: smtp.c:308
smtp_rcpt_to
static int smtp_rcpt_to(struct SmtpAccountData *adata, const struct AddressList *al)
Set the recipient to an Address.
Definition: smtp.c:197
mutt_istr_startswith
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
Definition: string.c:172
cs_subset_slist
const struct Slist * cs_subset_slist(const struct ConfigSubset *sub, const char *name)
Get a string-list config item by name.
Definition: helpers.c:198
Url::host
char * host
Host.
Definition: url.h:72
mutt_account_getoauthbearer
char * mutt_account_getoauthbearer(struct ConnAccount *cac)
Get an OAUTHBEARER token.
Definition: connaccount.c:158
ConnAccount::pass
char pass[256]
Password.
Definition: connaccount.h:56
ListNode::data
char * data
String.
Definition: list.h:36
SMTP_READY
#define SMTP_READY
Definition: smtp.c:61
SMTP_CAP_SMTPUTF8
#define SMTP_CAP_SMTPUTF8
Server accepts UTF-8 strings.
Definition: smtp.c:85
mutt_progress_update
void mutt_progress_update(struct Progress *progress, size_t pos, int percent)
Update the state of the progress bar.
Definition: progress.c:212
plen
static size_t plen
Length of cached packet.
Definition: pgppacket.c:39
MUTT_SOCK_LOG_FULL
#define MUTT_SOCK_LOG_FULL
Definition: mutt_socket.h:31
ConnAccount::service
const char * service
Name of the service, e.g. "imap".
Definition: connaccount.h:60
mutt_fqdn
const char * mutt_fqdn(bool may_hide_host, const struct ConfigSubset *sub)
Get the Fully-Qualified Domain Name.
Definition: sendlib.c:1182
MUTT_CA_USER
@ MUTT_CA_USER
User name.
Definition: connaccount.h:35
mutt_ssl_starttls
int mutt_ssl_starttls(struct Connection *conn)
Negotiate TLS over an already opened connection.
Definition: gnutls.c:1136
mutt_account_getuser
int mutt_account_getuser(struct ConnAccount *cac)
Retrieve username into ConnAccount, if necessary.
Definition: connaccount.c:48
mutt_addr_uses_unicode
bool mutt_addr_uses_unicode(const char *str)
Does this address use Unicode character.
Definition: address.c:1510
mutt_message
#define mutt_message(...)
Definition: logging.h:83
smtp_auth_sasl
static int smtp_auth_sasl(struct SmtpAccountData *adata, const char *mechlist)
Authenticate using SASL.
Definition: smtp.c:437
mutt_conn_find
struct Connection * mutt_conn_find(const struct ConnAccount *cac)
Find a connection from a list.
Definition: mutt_socket.c:86
SMTP_ERR_READ
#define SMTP_ERR_READ
Definition: smtp.c:64
Connection::ssf
unsigned int ssf
Security strength factor, in bits (see below)
Definition: connection.h:37
ConnAccount::user
char user[128]
Username.
Definition: connaccount.h:55
smtp_success
#define smtp_success(x)
Definition: smtp.c:60
LL_DEBUG2
@ LL_DEBUG2
Log at debug level 2.
Definition: logging.h:41
MUTT_CA_OAUTH_CMD
@ MUTT_CA_OAUTH_CMD
OAuth refresh command.
Definition: connaccount.h:37
SMTP_CAP_NO_FLAGS
#define SMTP_CAP_NO_FLAGS
No flags are set.
Definition: smtp.c:80
smtp_get_resp
static int smtp_get_resp(struct SmtpAccountData *adata)
Read a command response from the SMTP server.
Definition: smtp.c:147
mutt_account_getpass
int mutt_account_getpass(struct ConnAccount *cac)
Fetch password into ConnAccount, if necessary.
Definition: connaccount.c:111
mutt_socket_send_d
#define mutt_socket_send_d(conn, buf, dbg)
Definition: mutt_socket.h:38
Address
An email address.
Definition: address.h:34
mutt_error
#define mutt_error(...)
Definition: logging.h:84
Slist
String list.
Definition: slist.h:46
mutt_str_copy
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:716