/* Reads a command response from the SMTP server. * Returns: * 0 on success (2xx code) or continue (354 code) * -1 write error, or any other response code */ static int smtp_get_resp (CONNECTION * conn) { int n; char buf[1024]; do { n = mutt_socket_readln (buf, sizeof (buf), conn); if (n < 4) { /* read error, or no response code */ return smtp_err_read; } if (!ascii_strncasecmp ("8BITMIME", buf + 4, 8)) mutt_bit_set (Capabilities, EIGHTBITMIME); else if (!ascii_strncasecmp ("AUTH ", buf + 4, 5)) { mutt_bit_set (Capabilities, AUTH); FREE (&AuthMechs); AuthMechs = safe_strdup (buf + 9); } else if (!ascii_strncasecmp ("DSN", buf + 4, 3)) mutt_bit_set (Capabilities, DSN); else if (!ascii_strncasecmp ("STARTTLS", buf + 4, 8)) mutt_bit_set (Capabilities, STARTTLS); if (smtp_code (buf, n, &n) < 0) return smtp_err_code; } while (buf[3] == '-'); if (smtp_success (n) || n == smtp_continue) return 0; mutt_error (_("SMTP session failed: %s"), buf); return -1; }
/* open POP mailbox - fetch only headers */ int pop_open_mailbox(CONTEXT *ctx) { int ret; char buf[LONG_STRING]; CONNECTION *conn; ACCOUNT acct; POP_DATA *pop_data; ciss_url_t url; if (pop_parse_path(ctx->path, &acct)) { mutt_error(_("%s is an invalid POP path"), ctx->path); mutt_sleep(2); return -1; } mutt_account_tourl(&acct, &url); url.path = NULL; url_ciss_tostring(&url, buf, sizeof(buf), 0); conn = mutt_conn_find(NULL, &acct); if (!conn) return -1; safe_free(&ctx->path); ctx->path = safe_strdup(buf); pop_data = safe_calloc(1, sizeof(POP_DATA)); pop_data->conn = conn; ctx->data = pop_data; ctx->mx_close = pop_close_mailbox; if (pop_open_connection(pop_data) < 0) return -1; conn->data = pop_data; pop_data->bcache = mutt_bcache_open(&acct, NULL); /* init (hard-coded) ACL rights */ memset(ctx->rights, 0, sizeof(ctx->rights)); mutt_bit_set(ctx->rights, M_ACL_SEEN); mutt_bit_set(ctx->rights, M_ACL_DELETE); FOREVER { if (pop_reconnect(ctx) < 0) return -1; ctx->size = pop_data->size; mutt_message _("Fetching list of messages..."); ret = pop_fetch_headers(ctx); if (ret >= 0) return 0; if (ret < -1) { mutt_sleep(2); return -1; } } }