Archived Forum Post

Index of archived forum posts

Question:

POP3 SSL error while using sample code

Nov 18 '16 at 00:30

Hi,

I have tried the code here: *https://www.example-code.com/vcpp/pop3_ssl.asp*

and I get an error :

PopCmdSent: STAT
sockRecv: Socket connection closed.
Failed to read beginning of SSL/TLS record.

can you help me ???

Reagrds Greg

P.S: Full log is :

ChilkatLog:

CopyMail:

DllDate: Nov 13 2016

ChilkatVersion: 9.5.0.64

UnlockPrefix: 30-day trial

Architecture: Little Endian; 32-bit

Language: Visual C++ 6.0

VerboseLogging: 0

pop3OpenConnection:

  closePopConnection:

    No POP3 socket connection exists.

  --closePopConnection

  Connecting to POP3 server

  hostname: pop3.live.com

  port: 995

  tls: 1

  connectTimeoutMs: 30000

  isInSshTunnel: 0

  Connected to POP3 server

  socketOptions:

    SO_SNDBUF: 262144

    SO_RCVBUF: 4194304

    TCP_NODELAY: 1

    SO_KEEPALIVE: 1

  --socketOptions

  PopCmdResp: +OK DUB006-POP162 POP3 server ready

  greeting: +OK DUB006-POP162 POP3 server ready

  ConnectionType: SSL/TLS

--pop3OpenConnection

Pop3Authenticate:

  username: xxxxxxxxxxxxxxxxxxxx

  popSPA: 0

  PopCmdSent: USER xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

  PopCmdResp: +OK password required

  PopCmdSent: PASS ****

  PopCmdResp: +OK User successfully authenticated. [AuthResult=0 `Proxy=AM5PR10MB0420.EURPRD10.PROD.OUTLOOK.COM:1995:SSL]

  POP3 authentication success

--Pop3Authenticate

PopCmdSent: STAT

sockRecv: Socket connection closed.

Failed to read beginning of SSL/TLS record.

b: 0

dbSize: 0

nReadNBytes: 0

Failed to receive more TLS applicaton data.

pop3_getResponseN2: Socket connection closed.

Failed to received remainder of POP3 multi-line response.

matchStr:

Failed to get STAT response

--CopyMail

--ChilkatLog


Answer

I tested it just now, and it worked fine. See this example:

Android: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

Classic ASP: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

C: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

C++: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

C#: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

C# UWP/WinRT: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

DataFlex: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

Delphi ActiveX: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

Delphi DLL: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

.NET Core C#: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

Excel: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

Visual FoxPro: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

Java: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

Lianja: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

MFC: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

Mono C#: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

Node.js: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

Objective-C: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

Perl: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

PHP ActiveX: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

PHP Extension: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

PowerBuilder: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

PowerShell: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

PureBasic: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

Python: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

Ruby: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

SQL Server: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

Swift: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

Tcl: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

Unicode C: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

Unicode C++: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

Visual Basic 6.0: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

VB.NET: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

VB.NET UWP/WinRT: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

VBScript: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)

Xojo Plugin: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)


Answer

Thank you :-)

But it is very strange.....

The first example I ran gives me always the error. Then I tried the example you just send me ("MFC: Test HotMail POP3 (pop3.live.com or pop-mail.outlook.com)" ) and it runs without problem.... then I retry the first example ... and now .... it runs also OK ????

The two example are not exactly the same... I placed the first example below. I see that the first example use mailman.put_PopSsl(true); / mailman.CopyMail(); (and then CkEmailBundle *bundle) and the second use mailman.put_PopSsl(true); / mailman.Pop3Connect(); / mailman.Pop3Authenticate(); / mailman.CheckMail(); without CkEmailBundle.

Is the example I first use a little bit too simple ? What is the right way to go ? can I use CkEmailBundle (and bundle->GetEmail(i);) with the second example ?

Regards

Greg

PS : the code :

void CEMail_test_Dlg::OnTest() { // The mailman object is used for receiving (POP3) // and sending (SMTP) email. CkMailMan mailman;

UpdateData(true);
m_EditPlainText="";

//  Any string argument automatically begins the 30-day trial.
bool success = mailman.UnlockComponent("30-day trial");
if (success != true) {
    //std::cout << "Component unlock failed" << "\r\n";
    m_EditPlainText+="Component unlock failed \r\n";
    UpdateData(false);
    return;
}

//  Set the POP3 server's hostname
mailman.put_MailHost("pop3.live.com");

//  Set the POP3 login/password.
mailman.put_PopUsername("xyz@hotmail.com");
mailman.put_PopPassword("abcdef");

//  Indicate that we want TLS/SSL.  Also, set the port to 995:
mailman.put_MailPort(995);
mailman.put_PopSsl(true);

CkEmailBundle *bundle = 0;
//  Read mail headers and one line of the body.
bundle = mailman.CopyMail();

if (bundle == 0 ) {
    //std::cout << mailman.lastErrorText() << "\r\n";
    m_EditPlainText+=mailman.lastErrorText() ;
    m_EditPlainText+="\r\n";
    UpdateData(false);
    return;
}

int i;
CkEmail *email = 0;
for (i = 0; i <= bundle->get_MessageCount() - 1; i++) {
    email = bundle->GetEmail(i);

    //  Display the From email address and the subject.
    //std::cout << "From: " << email->ck_from() << "\r\n";
    //std::cout << "Subject: " << email->subject() << "\r\n";
    m_EditPlainText+="From: " ;
    m_EditPlainText+=email->ck_from() ;
    m_EditPlainText+= "\r\n";
    m_EditPlainText+="Subject: " ;
    m_EditPlainText+= email->subject() ;
    m_EditPlainText+= "\r\n";
    delete email;
}

delete bundle;

UpdateData(false);

}


Answer

Thanks.. I'll also test by directly calling CopyMail at the start..


Answer

I had no trouble. Here's my example with the session log:

http://www.example-code.com/cpp/mailman_hotmail_copymail.asp


Answer

Thank you :-)

As I was trying to get my emails, I remarks that it only returns email from the 'inbox' folder. Is there a way to get folder list and then email inside a specific folder ?

Regards Greg


Answer

Oups.... forgett my last question.... I found the answer ! (https://www.chilkatsoft.com/p/p_229.asp)

Many thanks Greg