IMAP connection carriage return line feed issue from linux?
Asked Answered
P

2

6

I'm attempting to connect to our exchange server using Mail::IMAPClient but a script that was working is having issues when I moved it from a temp dev desktop running ubuntu to a new dev env running centos. During that time I found out the exchange server was upgraded I think to 2010. Is there a setting in exchange that would allow commands to be processed with just linefeeds instead of requiring crlf or could this be a local system (running the script issue)?

This just times out after a while.

$openssl s_client -connect myhost.mydomain.net:993
...
* OK The Microsoft Exchange IMAP4 service is ready - 'myhost'
? login username password
* BYE Connection is closed. 13
read:errno=0

Commands would function correctly.

$openssl s_client -crlf -connect myhost.mydomain.net:993
...
* OK The Microsoft Exchange IMAP4 service is ready - 'myhost'
? login username password
? OK LOGIN completed.
? select inbox
* 4 EXISTS
* 0 RECENT
* FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)
* OK [PERMANENTFLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)] Permanent     flags
* OK [UNSEEN 3] Is the first unseen message
* OK [UIDVALIDITY 169533] UIDVALIDITY value
* OK [UIDNEXT 132] The next unique identifier value
? OK [READ-WRITE] SELECT completed.
1 logout
* BYE Microsoft Exchange Server 2010 IMAP4 server signing off.
1 OK LOGOUT completed.
read:errno=0

[Solution:]
Tried to make a manual ssl connection to the server using openssl.
I had to include the -crlf option so that exchange could recognize the IMAP commands terminating.

Polenta answered 30/12, 2011 at 19:2 Comment(0)
R
4

IMAP protocol requires the client and server to use \r\n. Exchange behaves correctly (which is not that common).

Rocco answered 13/4, 2012 at 20:32 Comment(1)
Interesting I didn't read the RFC if IMAP required that or not. Thanks for the info.Polenta
K
7

It's in section 2.2 of RFC3501, but that's part of the overview.

All interactions transmitted by client and server are in the form of lines, that is, strings that end with a CRLF.

Note that there is no "MUST" in the clause.

Dovecot and other IMAP servers are more liberal about what they accept, in terms of what constitutes an EOL.

"Correctness" is relative. If there's no MUST or SHOULD clause it's generally accepted that "be liberal in what you accept and strict in what you send" is the best way forward when implementing RFCs.

Knowhow answered 20/2, 2013 at 15:1 Comment(0)
R
4

IMAP protocol requires the client and server to use \r\n. Exchange behaves correctly (which is not that common).

Rocco answered 13/4, 2012 at 20:32 Comment(1)
Interesting I didn't read the RFC if IMAP required that or not. Thanks for the info.Polenta

© 2022 - 2024 — McMap. All rights reserved.