OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
Re: transport/pipe and whitespace in mime headers

From: Victor Duchovni (Victor.DuchovniMorganStanley.com)
Date: Thu May 04 2006 - 10:46:24 CDT


On Thu, May 04, 2006 at 04:11:50PM +0200, Christian Burkert wrote:

> Hi
>
> I am using the transport/pipe stuff by providing a shell script which reads the message from stdin and handles it. But unfortunatly I have some problems with whitespace. Example:
>
> I send a mail with a header like:
>
> -----
> Received: from lb1.amedeskg.de by node2.amedeskg.de
> with ESMTP id 8812691146754334; Thu, 04 May 2006 16:52:14 +0200
> Message-ID: <26443969.1146754334558.JavaMail.oraclenode2.amedeskg.de>
> Date: Thu, 4 May 2006 16:52:14 +0200 (CEST)
> From: "Christian Burkert" <christian.burkertprodatis.com>
> To: foobar.de
> Subject: Betreff
> Mime-Version: 1.0
> Content-Type: text/plain;charset=us-ascii
> Content-Transfer-Encoding: 7bit
> -----
>
> You see, that there is whitspace in the beginning of the second line. But in my script which reads the pipe I get:
>
> -----
> Received: from lb1.amedeskg.de by node2.amedeskg.de
> with ESMTP id 8812691146754334; Thu, 04 May 2006 16:52:14 +0200
> Message-ID: <26443969.1146754334558.JavaMail.oraclenode2.amedeskg.de>
> Date: Thu, 4 May 2006 16:52:14 +0200 (CEST)
> From: "Christian Burkert" <christian.burkertprodatis.com>
> To: foobar.de
> Subject: Betreff
> Mime-Version: 1.0
> Content-Type: text/plain;charset=us-ascii
> Content-Transfer-Encoding: 7bit
> -----
>
> So the whitespace in the second line has gone which causes several problems with my mime library.
> Here some information about the setup running postfix-2.2.10-1 on RHEL3:
>
> My transport file contains:
> -----
> faxtest.amedeskg.de faxtest:
> -----
>
> My master file contains:
> -----
> faxtest unix - n n - - pipe
> flags=q user=fax argv=/bin/bash /opt/fax/scripts/mail2fax.sh.tmp ${sender} ${recipient}
> -----
>
> And my bash-script /opt/fax/scripts/mail2fax.sh.tmp contains:
> -----
> rm -f ${msg}
> while read input; do
> echo "${input}" >> ${msg}
> done

Read the shell manual page, specifically the "read" built-in command.
This has nothing to do with Postfix. The above loop is really much better
handled via cat(1):

        msg=$(mktemp /var/tmp/msg.XXXXXX)
        trap "rm -f $msg" 0
        cat >> ${msg}
        ...

--
        Viktor.

P.S. Morgan Stanley is looking for a New York City based, Senior Unix
     system/email administrator to architect and sustain the Unix email
     environment. If you are interested, please drop me a note.

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the "Reply-To" header.

To unsubscribe from the postfix-users list, visit
http://www.postfix.org/lists.html or click the link below:
<mailto:majordomopostfix.org?body=unsubscribe%20postfix-users>

If my response solves your problem, the best way to thank me is to not
send an "it worked, thanks" follow-up. If you must respond, please put
"It worked, thanks" in the "Subject" so I can delete these quickly.