0 votes
ago by (120 points)

hi,
thanks for your awful software and support

using Rebex.Common R6.11 for .NET 4.6-4.8 I get an error 21 on RETR command
(we tried with equal to 1, 10, 100, 1000 with same error result)

We are using (since 2022) a POP client + OAUth2 in Office365, connecting and logging to server seems fine, failing on GetMailMessage()...

                // get list of all messages
            int count = _popClient.GetMessageCount();

            for (int seqNo = count; seqNo >= 1; seqNo--)
            {
                var mail = _popClient.GetMailMessage(seqNo)
... etc etc;

The error raised a few days ago: the Rebex-based client and the envirnoment (OS, ERP software, etc ) has not been upgraded nor re-installed.

My first thought was an issue with server certificates, but log did not raise error with it...
The customer IT specialist checked the server configuration and seems fine

please find attached the full log

Thanks
Gianfranco

2025-10-07 14:45:30.160 Opening log file.
2025-10-07 14:45:30.160 INFO FileLogWriter(5)[1] Info: Assembly: Rebex.Common R6.11 for .NET 4.6-4.8
2025-10-07 14:45:30.160 INFO FileLogWriter(5)[1] Info: Platform: Windows 6.2.9200 32-bit; CLR: 4.0.30319.42000
2025-10-07 14:45:30.160 DEBUG FileLogWriter(5)[1] Info: Culture: en; Windows-1252
2025-10-07 14:45:30.670 DEBUG Pop3(5)[14] Info: State changed from 'Disconnected' to 'Connecting'.
2025-10-07 14:45:30.670 INFO Pop3(5)[14] Info: Connecting to outlook.office365.com:995 using Pop3.
2025-10-07 14:45:30.670 INFO Pop3(5)[14] Info: Assembly: Rebex.Pop3 R6.11 for .NET 4.6-4.8
2025-10-07 14:45:30.676 INFO Pop3(5)[14] Info: Platform: Windows 6.2.9200 32-bit; CLR: 4.0.30319.42000
2025-10-07 14:45:30.676 DEBUG Pop3(5)[14] Info: Culture: en; Windows-1252
2025-10-07 14:45:30.686 INFO Pop3(5)[14] Info: Connecting to 52.98.237.162.
2025-10-07 14:45:30.686 DEBUG Pop3(5)[14] Proxy: Connecting to 52.98.237.162:995 (no proxy).
2025-10-07 14:45:30.686 DEBUG Pop3(5)[14] Proxy: Connection established.
2025-10-07 14:45:30.686 DEBUG Pop3(5)[14] Info: Connection succeeded.
2025-10-07 14:45:30.686 DEBUG Pop3(5)[14] Info: Upgrading connection to TLS.
2025-10-07 14:45:30.686 DEBUG Pop3(5)[14] TLS: Using classic TLS core.
2025-10-07 14:45:30.686 DEBUG Pop3(5)[14] TLS: Enabled cipher suites: 0x000F3DF7EBE00640.
2025-10-07 14:45:30.686 DEBUG Pop3(5)[14] TLS: Applicable cipher suites: 0x000F3DF7EBE00640.
2025-10-07 14:45:30.686 DEBUG Pop3(5)[14] TLS: HandshakeMessage:ClientHello was sent.
2025-10-07 14:45:30.776 DEBUG Pop3(5)[14] TLS: HandshakeMessage:ServerHello was received.
2025-10-07 14:45:30.776 INFO Pop3(5)[14] TLS: Negotiating TLS 1.2, RSA with ephemeral ECDH, AES with 256-bit key in GCM mode, AEAD.
2025-10-07 14:45:30.776 DEBUG Pop3(5)[14] TLS: The server supports secure renegotiation.
2025-10-07 14:45:30.776 DEBUG Pop3(5)[14] TLS: Extended master secret is enabled.
2025-10-07 14:45:30.776 DEBUG Pop3(5)[14] TLS: HandshakeMessage:Certificate was received.
2025-10-07 14:45:30.776 DEBUG Pop3(5)[14] TLS: HandshakeMessage:ServerKeyExchange was received.
2025-10-07 14:45:30.776 DEBUG Pop3(5)[14] TLS: HandshakeMessage:ServerHelloDone was received.
2025-10-07 14:45:30.776 DEBUG Pop3(5)[14] TLS: Verifying server certificate ('CN=outlook.com, O=Microsoft Corporation, L=Redmond, S=Washington, C=US').
2025-10-07 14:45:30.776 DEBUG Pop3(5)[14] TLS: Certificate verification result: Accept
2025-10-07 14:45:30.776 DEBUG Pop3(5)[14] TLS: Verifying server key exchange signature.
2025-10-07 14:45:30.776 DEBUG Pop3(5)[14] TLS: Using ephemeral ECDH public key exchange with NIST P-256 curve.
2025-10-07 14:45:30.776 DEBUG Pop3(5)[14] TLS: HandshakeMessage:ClientKeyExchange was sent.
2025-10-07 14:45:30.776 DEBUG Pop3(5)[14] TLS: CipherSpec:ChangeCipherSpec was sent.
2025-10-07 14:45:30.776 DEBUG Pop3(5)[14] TLS: HandshakeMessage:Finished was sent.
2025-10-07 14:45:30.776 DEBUG Pop3(5)[14] TLS: CipherSpec:ChangeCipherSpec was received.
2025-10-07 14:45:30.776 DEBUG Pop3(5)[14] TLS: HandshakeMessage:Finished was received.
2025-10-07 14:45:30.776 INFO Pop3(5)[14] TLS: Connection secured using cipher: TLS 1.2, RSA with ephemeral ECDH, AES with 256-bit key in GCM mode, AEAD.
2025-10-07 14:45:30.776 DEBUG Pop3(5)[14] Info: Connection upgraded to TLS 1.2.
2025-10-07 14:45:30.834 DEBUG Pop3(5)[14] Info: State changed from 'Connecting' to 'Reading'.
2025-10-07 14:45:30.834 INFO Pop3(5)[14] Response: +OK The Microsoft Exchange POP3 service is ready. [TQBJADEAUAAyADkAMwBDAEEAMAAwADIAMwAuAEkAVABBAFAAMgA5ADMALgBQAFIATwBEAC4ATwBVAFQATABPAE8ASwAuAEMATwBNAA==]
2025-10-07 14:45:30.834 DEBUG Pop3(5)[14] Info: State changed from 'Reading' to 'Ready'.
2025-10-07 14:45:30.834 DEBUG Pop3(5)[14] Info: State changed from 'Ready' to 'Sending'.
2025-10-07 14:45:30.834 INFO Pop3(5)[14] Command: CAPA
2025-10-07 14:45:30.834 DEBUG Pop3(5)[14] Info: State changed from 'Sending' to 'Reading'.
2025-10-07 14:45:30.855 INFO Pop3(5)[14] Response: +OK
2025-10-07 14:45:30.855 DEBUG Pop3(5)[14] Info: State changed from 'Reading' to 'Downloading'.
2025-10-07 14:45:30.855 DEBUG Pop3(5)[14] Response: TOP
2025-10-07 14:45:30.855 DEBUG Pop3(5)[14] Response: UIDL
2025-10-07 14:45:30.855 DEBUG Pop3(5)[14] Response: SASL PLAIN XOAUTH2
2025-10-07 14:45:30.855 DEBUG Pop3(5)[14] Response: USER
2025-10-07 14:45:30.855 DEBUG Pop3(5)[14] Response: .
2025-10-07 14:45:30.855 DEBUG Pop3(5)[14] Info: State changed from 'Downloading' to 'Ready'.
2025-10-07 14:45:30.855 DEBUG Pop3(5)[14] Info: State changed from 'Ready' to 'Sending'.
2025-10-07 14:45:30.855 INFO Pop3(5)[14] Command: AUTH XOAUTH2
2025-10-07 14:45:30.855 DEBUG Pop3(5)[14] Info: State changed from 'Sending' to 'Reading'.
2025-10-07 14:45:30.876 INFO Pop3(5)[14] Response: + 
2025-10-07 14:45:30.876 DEBUG Pop3(5)[14] Info: State changed from 'Reading' to 'Ready'.
2025-10-07 14:45:30.876 DEBUG Pop3(5)[14] Info: State changed from 'Ready' to 'Sending'.
2025-10-07 14:45:30.876 INFO Pop3(5)[14] Command: dXNl...RAQE=
2025-10-07 14:45:30.876 DEBUG Pop3(5)[14] Info: State changed from 'Sending' to 'Reading'.
2025-10-07 14:45:34.150 INFO Pop3(5)[14] Response: +OK User successfully authenticated.
2025-10-07 14:45:34.150 DEBUG Pop3(5)[14] Info: State changed from 'Reading' to 'Ready'.
2025-10-07 14:45:41.016 DEBUG Pop3(5)[1] Info: State changed from 'Ready' to 'Sending'.
2025-10-07 14:45:41.016 INFO Pop3(5)[1] Command: STAT
2025-10-07 14:45:41.016 DEBUG Pop3(5)[1] Info: State changed from 'Sending' to 'Reading'.
2025-10-07 14:45:41.410 INFO Pop3(5)[1] Response: +OK 729 48731813
2025-10-07 14:45:41.410 DEBUG Pop3(5)[1] Info: State changed from 'Reading' to 'Ready'.
2025-10-07 14:50:40.346 DEBUG Pop3(5)[1] Info: State changed from 'Ready' to 'Sending'.
**2025-10-07 14:50:40.346 INFO Pop3(5)[1] Command: RETR 729
2025-10-07 14:50:40.346 DEBUG Pop3(5)[1] Info: State changed from 'Sending' to 'Reading'.
2025-10-07 14:50:44.324 INFO Pop3(5)[1] Response: -ERR Server Unavailable. 21
2025-10-07 14:50:44.324 DEBUG Pop3(5)[1] Info: State changed from 'Reading' to 'Ready'.
2025-10-07 14:50:44.340 ERROR Pop3(5)[1] Info: Rebex.Net.Pop3Exception: Server Unavailable. 21
   at Rebex.Net.Pop3.nungs(Boolean p0, Boolean p1, String& p2)
   at Rebex.Net.Pop3.tawse(Int32 p0, Stream p1)
2025-10-07 14:51:15.666 DEBUG Pop3(5)[1] Info: State changed from 'Ready' to 'Sending'.
2025-10-07 14:51:15.666 INFO Pop3(5)[1] Command: QUIT
2025-10-07 14:51:15.666 DEBUG Pop3(5)[1] Info: State changed from 'Sending' to 'Reading'.
2025-10-07 14:51:15.825 INFO Pop3(5)[1] Response: +OK Microsoft Exchange Server POP3 server signing off.
2025-10-07 14:51:15.825 DEBUG Pop3(5)[1] Info: State changed from 'Reading' to 'Downloading'.
2025-10-07 14:51:15.825 DEBUG Pop3(5)[1] TLS: Closing TLS socket.
2025-10-07 14:51:15.825 DEBUG Pop3(5)[1] TLS: Alert:CloseNotify was sent.
2025-10-07 14:51:15.825 DEBUG Pop3(5)[1] Info: State changed from 'Downloading' to 'Disconnected'.
Applies to: Rebex Secure Mail
ago by (75.9k points)
If the issue persists, please try to skip messages which reports error like this:

    for (int seqNo = count+2; seqNo >= 1; seqNo--)
    {
        try
        {
            pop3.GetMailMessage(seqNo);
        }
        catch (Pop3Exception ex)
        {
            Console.WriteLine("Cannot download message '{0}': {1}", seqNo, ex.Message);
        }
    }

Does all messages report the error?

1 Answer

0 votes
ago by (75.9k points)

Thank you for providing the log. The error is being returned directly by the outlook.office365.com POP3 server.

Authentication completes successfully, so the client and server configuration appear correct. The first POP3 command after authentication (STAT) succeeds, but the second command (RETR) returns: -ERR Server Unavailable. 21

That response is generated server-side and isn’t something the client can control. It may have been a temporary service issue. I’ve just tested retrieving a message from outlook.office365.com via POP3, and it worked as expected. Please see my log:

2025-10-08 11:57:08.237 INFO Pop3(1)[4] Info: Connecting to outlook.office365.com:995 using Pop3.
2025-10-08 11:57:08.240 INFO Pop3(1)[4] Info: Assembly: Rebex.Pop3 R6.11 for .NET 4.6-4.8
2025-10-08 11:57:08.242 INFO Pop3(1)[4] Info: Platform: Windows 6.2.9200 64-bit; CLR: 4.0.30319.42000
2025-10-08 11:57:08.268 INFO Pop3(1)[4] Info: Connecting to 52.97.154.162.
2025-10-08 11:57:08.494 INFO Pop3(1)[4] TLS: Negotiating TLS 1.2, RSA with ephemeral ECDH, AES with 256-bit key in GCM mode, AEAD.
2025-10-08 11:57:08.668 INFO Pop3(1)[4] TLS: Connection secured using cipher: TLS 1.2, RSA with ephemeral ECDH, AES with 256-bit key in GCM mode, AEAD.
2025-10-08 11:57:08.716 INFO Pop3(1)[4] Response: +OK The Microsoft Exchange POP3 service is ready. [VgBJADEAUABSADAANgBDAEEAMAAxADUAOQAuAGUAdQByAHAAcgBkADAANgAuAHAAcgBvAGQALgBvAHUAdABsAG8AbwBrAC4AYwBvAG0A]
2025-10-08 11:57:08.723 INFO Pop3(1)[4] Command: CAPA
2025-10-08 11:57:08.729 INFO Pop3(1)[4] Response: +OK
2025-10-08 11:57:08.746 INFO Pop3(1)[5] Command: AUTH XOAUTH2
2025-10-08 11:57:08.751 INFO Pop3(1)[5] Response: +
2025-10-08 11:57:08.753 INFO Pop3(1)[5] Command: dXNl...BAQE=
2025-10-08 11:57:09.672 INFO Pop3(1)[5] Response: +OK User successfully authenticated.
2025-10-08 11:57:09.674 INFO Pop3(1)[5] Command: STAT
2025-10-08 11:57:09.787 INFO Pop3(1)[5] Response: +OK 2 58473
2025-10-08 11:57:09.792 INFO Pop3(1)[5] Command: RETR 2
2025-10-08 11:57:09.941 INFO Pop3(1)[5] Response: +OK
2025-10-08 11:57:10.074 INFO Pop3(1)[5] Command: RETR 1
2025-10-08 11:57:10.209 INFO Pop3(1)[5] Response: +OK
2025-10-08 11:57:10.263 INFO Pop3(1)[5] Command: QUIT
2025-10-08 11:57:10.422 INFO Pop3(1)[5] Response: +OK Microsoft Exchange Server POP3 server signing off.
...