2 * Copyright (C) 1999-2001 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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
19 /* plain LOGIN support */
22 #include "imap_private.h"
25 /* imap_auth_login: Plain LOGIN support */
26 imap_auth_res_t imap_auth_login (IMAP_DATA* idata, const char* method)
28 char q_user[SHORT_STRING], q_pass[SHORT_STRING];
32 if (mutt_bit_isset (idata->capabilities, LOGINDISABLED))
34 mutt_message _("LOGIN disabled on this server.");
35 return IMAP_AUTH_UNAVAIL;
38 if (mutt_account_getuser (&idata->conn->account))
39 return IMAP_AUTH_FAILURE;
40 if (mutt_account_getpass (&idata->conn->account))
41 return IMAP_AUTH_FAILURE;
43 mutt_message _("Logging in...");
45 imap_quote_string (q_user, sizeof (q_user), idata->conn->account.user);
46 imap_quote_string (q_pass, sizeof (q_pass), idata->conn->account.pass);
49 /* don't print the password unless we're at the ungodly debugging level
52 if (debuglevel < IMAP_LOG_PASS)
53 dprint (2, (debugfile, "Sending LOGIN command for %s...\n",
54 idata->conn->account.user));
57 snprintf (buf, sizeof (buf), "LOGIN %s %s", q_user, q_pass);
58 rc = imap_exec (idata, buf, IMAP_CMD_FAIL_OK | IMAP_CMD_PASS);
61 return IMAP_AUTH_SUCCESS;
63 mutt_error _("Login failed.");
65 return IMAP_AUTH_FAILURE;