问题
I want to read my Gmail inbox emails using c++ builder so I use this code I got it from videos on youtube, but before i read i tried to connect first using this code in the button.
MyPoP3
POP3->Host = "pop.gmail.com";
POP3->Port = 995;
POP3->Username = "@gmail.com";
POP3->Password = "my pass";
POP3->Connect();
Memo1->Text = "Number = " + IntToStr(MyPoP3->CheckMessages()) + "\n";
MyPoP3->Disconnect();
and i got this error message after a short delay.
error connection closed gracefully
this my first time iam use c++ builder I just learn it so please any help with that error because I can't find any good resource for it.
Thanks in advance.
回答1:
The error message means the server is closing its end of the TCP connection.
POP3 port 995 uses SSL encryption, so in order to communicate with Gmail on port 995, you must:
assign an
TIdSSLIOHandlerSocketBase
-derived component to theTIdPOP3.IOHandler
property, such asTIdSSLIOHandlerSocketOpenSSL
(and deploy the 2 OpenSSL DLLs with your app).set the
TIdPOP3.UseTLS
property toutUseImplicitTLS
.if you have 2-factor authentication enabled in your Gmail account, create an application-specific password for your app to use instead of your real Gmail password (as Indy does not yet implement support for OAuth authentication for POP3 and other protocols).
来源:https://stackoverflow.com/questions/51736890/read-gmail-pop3-using-c-builder