2 * Copyright (C) 1999-2001,2005 Brendan Cully <brendan@kublai.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 /* plain LOGIN support */
26 #include "imap_private.h"
29 /* imap_auth_login: Plain LOGIN support */
30 imap_auth_res_t imap_auth_login (IMAP_DATA* idata, const char* method)
32 char q_user[SHORT_STRING], q_pass[SHORT_STRING];
36 if (mutt_bit_isset (idata->capabilities, LOGINDISABLED))
38 mutt_message _("LOGIN disabled on this server.");
39 return IMAP_AUTH_UNAVAIL;
42 if (mutt_account_getlogin (&idata->conn->account))
43 return IMAP_AUTH_FAILURE;
44 if (mutt_account_getpass (&idata->conn->account))
45 return IMAP_AUTH_FAILURE;
47 mutt_message _("Logging in...");
49 imap_quote_string (q_user, sizeof (q_user), idata->conn->account.user);
50 imap_quote_string (q_pass, sizeof (q_pass), idata->conn->account.pass);
53 /* don't print the password unless we're at the ungodly debugging level
56 if (debuglevel < IMAP_LOG_PASS)
57 dprint (2, (debugfile, "Sending LOGIN command for %s...\n",
58 idata->conn->account.user));
61 snprintf (buf, sizeof (buf), "LOGIN %s %s", q_user, q_pass);
62 rc = imap_exec (idata, buf, IMAP_CMD_FAIL_OK | IMAP_CMD_PASS);
65 return IMAP_AUTH_SUCCESS;
67 mutt_error _("Login failed.");
69 return IMAP_AUTH_FAILURE;