read gmail pop3 using c++ builder

被刻印的时光 ゝ 提交于 2019-12-23 23:09:05

问题



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 the TIdPOP3.IOHandler property, such as TIdSSLIOHandlerSocketOpenSSL (and deploy the 2 OpenSSL DLLs with your app).

  • set the TIdPOP3.UseTLS property to utUseImplicitTLS.

  • 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!