Search code examples
imap

imap error after received Gimap ready for requests


I have an error when i run the code.

the following is the code:

void smtp_listener::imapLogin(QString reply)
{
    print_D(FUNC);
    print_D(QString("this is "+reply+"well"));
    if(reply.contains("OK"))
    {
        QString msg = QString("user %1").arg(user);
        print_D(msg);
        *t << msg <<"\r\r\n";
        t->flush();
        setState(POP3_Pass);
    }
    else
    {
        print_E("ERROR :"+reply,FUNC,__LINE__);
        quitConn();
        setState(POP3_Quit);
    }
}

void smtp_listener::pop3Pass(QString reply)
{
    print_D(FUNC);
    print_D(QString("this is "+reply+" well"));
    if(reply.contains("+OK"))
    {
        QString msg = QString("pass %1").arg(pass);
        *t << msg <<"\r\n";
        t->flush();

        setState(POP3_Stat);
    }
    else
    {
        print_E("ERROR :"+reply,FUNC,__LINE__);
        quitConn();
        setState(POP3_Quit);
    }
}

the error i give after i debug:

[Debug] "Email account : connected."

[Debug] "void smtp_listener::imapLogin(QString)"

[Debug] "this is * OK Gimap ready for requests from 140.101.159.251 q2-v6mb85227685wrd

well"

[Debug] "user chairouyih@gmail.com"

[Debug] "void smtp_listener::pop3Pass(QString)"

[Debug] "this is user BAD Unknown command q2-v6mb85227685wrd

well"

"[Error] ERROR :user BAD Unknown command q2-v6mb85227685wrd

at func=void smtp_listener::pop3Pass(QString) Line=361"

[Debug] "void smtp_listener::quitConn()"

[Debug] "void smtp_listener::pop3Quit(QString)"

[Debug] "* BAD invalid tag q2-v6mb85227685wrd


Solution

  • You are using POP3 commands with an IMAP server. They are not compatible, and their language is very different.

    For one, every IMAP command has a tag, and basic logging in is done with a LOGIN command. It would look something like this:

    a001 LOGIN user@gmail.com "password"
    

    If you want to use POP3, connect to the pop3 server at pop.gmail.com, with TLS enabled on port 995.