Re: Netsendmail inserts double line endings?

Richard Jones <[email protected]> Tue, 8 Feb 2005 14:22:47 +0000
Newsgroups gmane.comp.lang.ocaml.lib.net.devel
Message-ID <[email protected]>
On Mon, Feb 07, 2005 at 10:20:11PM +0100, Gerd Stolpmann wrote:
> The generated mail uses CR LF as line separator.

OK, I've confirmed that this is the case.  Although it is, of course,
correct to send CR LF in mail messages and the SMTP protocol, I'm not
sure that it's correct to send CR LF to /usr/sbin/sendmail.  Surely
the "protocol" being used between the process and /usr/sbin/sendmail
is pure Unix, therefore LF-terminated?

> Although this is the standard for the mail messages themselves, it
> might be that the "sendmail" command emulation of exim takes CR LF
> as LF LF. Just a hypothesis.

Exim doesn't mind about the CR LF in the mail headers.  In the body,
it gets confused, and appears to turn CR LF into LF LF.  By "body",
I'm also including the MIME headers for each of the two parts.

The *really* weird thing about this bug, however, is that it only
bites when sending mail non-locally.  I can send mail locally (through
exim), and it comes out just fine.  When I send it non-locally, we get
the bug.

Anyway, in the meantime I have been able to workaround the bug,
for both local and non-local mail, quite successfully, using:

Netsendmail.sendmail ~mailer:"tr -d '\\015' | /usr/sbin/sendmail" msg 

Attached is my test program.

Rich.

-- 
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Team Notepad - intranets and extranets for business - http://team-notepad.com
sendmail.ml (text/plain, 489 B)
(*ocamlc -I +pcre -I +netstring unix.cma pcre.cma netstring.cma sendmail.ml -o sendmail*)

let to_addrs = [ "Your Name", "[email protected]" ]

let csv_filename = "/etc/motd"

let attachments =
  [ Netsendmail.wrap_attachment
      ~content_type:("text/plain", [])
      (new Netmime.file_mime_body csv_filename) ]
let msg =
  Netsendmail.compose ~to_addrs ~attachments
    ~subject:"Subject line" "Body of main part";;

Netsendmail.sendmail ~mailer:"tr -d '\\015' | /usr/sbin/sendmail" msg