diff --git a/src/mail.cc b/src/mail.cc index 6786f9f4..e7208f76 100644 --- a/src/mail.cc +++ b/src/mail.cc @@ -55,6 +55,7 @@ #include #include +#include #include "update-cb.hh" @@ -536,7 +537,7 @@ std::unique_ptr parse_mail_args(mail_type type, const char *arg) term.c_lflag &= ~ECHO; tcsetattr(fp, TCSANOW, &term); printf("Enter mailbox password (%s@%s): ", user, host); - if (scanf("%128s", pass)) + if (scanf("%128s", pass) != 1) pass[0] = 0; printf("\n"); term.c_lflag |= ECHO; @@ -775,8 +776,11 @@ void imap_cb::work() if (strstr(recvbuf, " IDLE ") != NULL) has_idle = true; - command(sockfd, "a1 login " + get() + " " + get() + "\r\n", - recvbuf, "a1 OK"); + std::ostringstream str; + str << "a1 login " << get() << " {" << get().length() << "}\r\n"; + command(sockfd, str.str(), recvbuf, "+ OK"); + + command(sockfd, get() + "\r\n", recvbuf, "a1 OK"); command(sockfd, "a2 STATUS \"" + get() + "\" (MESSAGES UNSEEN)\r\n", recvbuf, "a2 OK");