smtp header / body separator

bash, smtp

Solution

This was defined originally in RFC 822 and it is `CR LF`. Look at section 3.1.

3.1. GENERAL DESCRIPTION A message consists of header fields and, optionally, a body. The body is simply a sequence of lines containing ASCII characters. It is separated from the headers by a null line (i.e., a line with nothing preceding the CRLF).

The most recent version is RFC 5322 and the relevant section is now 2.1. It is more comprehensive, but has still the same content, i.e. the separator is CRLF.

Problem

I need to separate the header and body of a smtp message in bash. I know that a newline is used to indicate the end of the header, but is it always `\n`, `\r` or `\r\n`, or do different operating systems use different ones? How can I do this?

Original source