postfix-users

Re: postfix sendmail and Mime

Subject: Re: postfix sendmail and Mime
From: Vance Wheelock <vance AT csh.rit DOT edu>
To: postfix-users AT postfix DOT org
Date: Wed, 08 Aug 2007 15:07:10 -0400
Vivek Khera wrote:
>
> On Aug 8, 2007, at 12:13 PM, Vance Wheelock wrote:
>
>> What is the proper way to compose and Mime encoded message so that this
>> will properly work in Outlook.
>
> Don't put *any* empty lines before your headers end.  The empty line
> indicates your headers are done.  Postfix is doing the right thing. 
> Outlook (shockingly) is doing the right thing.
I understand the rfc822/2045 structure pretty well. The strange part is
that I'm not inserting any extra newlines. This is my perl code
================================================
  open (MAIL, "| $sendmail -t -f \"$fromemail\"") or die
("Unable to open sendmail");
  print MAIL "From: $from\n";
   print MAIL "To: $to\n";
   print MAIL "Subject: $subject\n";
   if ( $orig_msgID ) {
        print MAIL "References: $orig_msgID\n";
        print MAIL "In-Reply-To: $orig_msgID\n";
   }
   if ($is_html == 1) {
       print MAIL "MIME-Version: 1.0\n";
  }
   print MAIL "$body";
  close (MAIL) or die ("Unable to close sendmail");
==============================================================

The output message looks like:

======================================================================
From: xxx AT xxx DOT com
To: xxxx AT xxxxx DOT net
Subject: Teleblend test
References: <00e501c7d9e4$03a64e30$0200810a AT xxxx DOT net>
In-Reply-To: <00e501c7d9e4$03a64e30$0200810a AT xxxxx DOT net>
MIME-Version: 1.0
Content-Type: multipart/alternative;
  boundary="------------060108060008080501030900"
Message-Id: <20070808174614.4B8B757E78 AT xxxxx DOT com>
Date: Wed,  8 Aug 2007 13:46:14 -0400 (EDT)


This is a multi-part message in MIME format.
--------------060108060008080501030900
.......... message continues.

======================================================

The Message-Id: and Date: lines are appended by postfix's sendmail (as
far as I can tell). The two lines get appended at the very first empty
line. In this case since I do not have an extra cr/lf under the
"Mime-Version 1.0" line and my body is directly below the "Mime-Version
1.0" line, the two lines get pasted into the "body" of my message where
it finds it's first empty lines. The $body string starts with the lines

Content-Type: multipart/alternative;
  boundary="------------060108060008080501030900"

and then after this is a new line, and that is where the two lines are
being appeneded plus two cr/lf lines.

So I thought I could append an extra newline after the "Mime-Version
1.0" line and it would work. this works partially in that I get the
following result:

======================================================================
From: xxx AT xxx DOT com
To: xxxx AT xxxxx DOT net
Subject: Teleblend test
References: <00e501c7d9e4$03a64e30$0200810a AT xxxx DOT net>
In-Reply-To: <00e501c7d9e4$03a64e30$0200810a AT xxxxx DOT net>
MIME-Version: 1.0
Message-Id: <20070808174614.4B8B757E78 AT xxxxx DOT com>
Date: Wed,  8 Aug 2007 13:46:14 -0400 (EDT)


Content-Type: multipart/alternative;
  boundary="------------060108060008080501030900"

This is a multi-part message in MIME format.
--------------060108060008080501030900
.......... message continues.

======================================================


But the problem is that there are two cr/lf
occurring after the "Date:" line which is what is breaking the header
from the body. I don't have any control over the two extra cr/lf that
are occurring and am wondering how I can fix this. If I could suppress
the two lines that postfix's sendmail is attaching or somehow get rid of
the newlines I would be happy. Or if someone sees something wrong with
the perlcode, please let me know.

Thanks in advance.





<Prev in Thread] Current Thread [Next in Thread>