Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IMAP connection carriage return line feed issue from linux?

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.

like image 420
krizzo Avatar asked Dec 30 '11 19:12

krizzo


2 Answers

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.

like image 169
Stoat Avatar answered Nov 16 '22 12:11

Stoat


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

like image 33
Pawel Lesnikowski Avatar answered Nov 16 '22 11:11

Pawel Lesnikowski