in reply to content-length first line
Preferrably over Sewi's solution, I'd look at using MIME::Lite instead of opening a socket to whatever incarnation of sendmail lives on your system directly. It's far less spam-prone and works even on Windows.