Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Problem sending a DOS text file from Linux to Windows.

165 views
Skip to first unread message

scott....@scottrix.co.uk

unread,
Feb 1, 2008, 10:11:19 AM2/1/08
to
On Fri, Feb 01, 2008 at 09:56:50AM -0500, Wietse Venema wrote:
>scott....@scottrix.co.uk:
>> Hi
>>
>> I am having a problem sending a Dos (CRLF) text file from Linux to Windows
>> as an attachment (mimetype = text/plain, encoding = 7bit). I am using mutt
>> as my email client and postfix (2.4.5) as my MTA. When the file is
>> received the CRLF has been replaced by CRLFCRLF, if I send the same file to
>> myself (on Linux) then the CRLF line endings have been replaced with LFLF.
>> Creating a double line spacing effect.
>>
>> To try to narrow down the problem I replaced the MTA that mutt uses with a
>> bash script to dump the file out to a log. This log showed that the
>> message still contained just one CRLF line ending on each line.
>>
>> I then ran tcpdump so monitor the outgoing smtp connect that postfix was
>> making. This showed that the line ending had changed from CRLF to CRCRLF.
>> I am guessing that something somewhere is changing the LF at the end of the
>> lines to CRLF despite the fact that each line already contains this
>> combination.
>>
>> I am not sure where to go from here to find out what is going on, any help
>> would be appreciated. If you require anymore information please let me
>> know.
>
>UNIX systems don't use DOS textfile formats. Use the unix2dos
>command (or similar tool) to properly handle DOS text files on a
>UNIX system.

From what I have managed to find on the web the SMTP protocol uses CRLF
text to transfer text data around, now I assume that postfix is doing the
conversion from unix text (LF) to SMTP text (CRLF), if the text is already
in that format and since it is text data and not binary is there a problem
with leaving text that is already (CRLF) alone ?

Regards,

Scott.

Victor Duchovni

unread,
Feb 1, 2008, 10:58:34 AM2/1/08
to
On Fri, Feb 01, 2008 at 03:46:05PM +0000, scott....@scottrix.co.uk wrote:

> >Local text MUST be in UNIX text format. Postfix will convert between
> >network formats and local formats.
>
> Are you saying that a DOS text file on Linux is actually a "binary" file
> and should not have a text/plain mime type ?
>
> If I wanted to modify this behaviour and "break" my system where in the
> postfix code does it do this conversion ?

tr -d '\015' < dos_text_file > real_text_file

Then mail the "real_text_file". If you want to undertake independent
Postfix development, ... good luck.

--
Viktor.

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:majo...@postfix.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.

Richard Foley

unread,
Feb 1, 2008, 11:30:04 AM2/1/08
to
On Friday 01 February 2008 16:46, scott....@scottrix.co.uk wrote:
> >Local text MUST be in UNIX text format. Postfix will convert between
> >network formats and local formats.
>
> Are you saying that a DOS text file on Linux is actually a "binary" file
> and should not have a text/plain mime type ?
>
> If I wanted to modify this behaviour and "break" my system where in the
> postfix code does it do this conversion ?
>
You're not listening to the answer:

Wietse said:

> To send DOS a textfile from a UNIX system use a DOS/UNIX conversion
> tool or send the file as a base64 encoded attachment.
>

--
Richard Foley
Ciao - shorter than aufwiedersehen

http://www.rfi.net/

Alexey Lobanov

unread,
Feb 4, 2008, 5:01:39 AM2/4/08
to
Hello.

04.02.2008 12:00, scott....@scottrix.co.uk пишет:

> On Fri, Feb 01, 2008 at 05:30:04PM +0100, Richard Foley wrote:
>> You're not listening to the answer:
>>
>> Wietse said:
>>
>>> To send DOS a textfile from a UNIX system use a DOS/UNIX conversion
>>> tool or send the file as a base64 encoded attachment.
>

> Let me try to put it another way. How do I know when I need to convert
> the file before I send it ?

Possibly nohow, as "fromdos" is a safe filter. It does nothing bad with
an unix text.

$ man fromdos
"The default is to remove carriage returns only if they are followed
by line feeds."

Alexey

mouss

unread,
Feb 4, 2008, 9:26:44 AM2/4/08
to
scott....@scottrix.co.uk wrote:
> On Fri, Feb 01, 2008 at 05:30:04PM +0100, Richard Foley wrote:
>> You're not listening to the answer:
>>
>> Wietse said:
>>
>>> To send DOS a textfile from a UNIX system use a DOS/UNIX conversion
>>> tool or send the file as a base64 encoded attachment.
>
> Let me try to put it another way. How do I know when I need to convert
> the file before I send it ? I don't intend to manually check every
> single text file that I send to see if I should then manually convert
> it first.
>
> Using the UNIX file utility with the "-i" option which lists the mime
> type it gives:
>
> text/plain; charset=us-ascii
>
> If this is correct, then shouldn't the MTA handle this mime type
> without screwing up the file ?
>
> Programmatically it is not difficult, so I assume that the negativity
> that I am getting is because I am not getting something, so please
> please explain why changing the code to cope with this would be a bad
> idea.
>
> Scott.
>
> PS. Tried the same thing with exim and this works as it should, i.e.
> doesn't introduce the extra CR in the attachment. I don't want to
> switch MTAs as I believe Postfix is better in many ways, but I also
> don't want to send out broken emails.

it's up to you (to switch to exim or not), but in principle you can't do

# sendmail ... < foo.mp4

mail data must obey some constraints.

with text files, you can still do
# dos2unix foo.txt | sendmail ....

the dos2unix command will convert the file to "unix format" if it was in
dos format.

Victor Duchovni

unread,
Feb 4, 2008, 10:10:43 AM2/4/08
to
On Mon, Feb 04, 2008 at 02:57:38PM +0000, scott....@scottrix.co.uk wrote:

> Sorry for being a pain, but I want to get this clear. I can only see two
> things that could be wrong to get to the problem I am having.
>
> 1) Postfix is broken and should be detecting when text/plain attachments
> have CRLF and not add the CR.

Postfix is an MTA. It is the MUA's responsibility to inject valid content.

> 2) My MUA (mutt) is broken and is incorrectly identifying a DOS text file
> as text/plain when it is not.

The MUA (mutt) is responsible for submitting valid content. What are you
doing with mutt, and what MIME content is mutt generating? Configure
mutt to use a custom "sendmail" that just saves the message to a disk
file. Report what you find in the disk file...

scott....@scottrix.co.uk

unread,
Feb 4, 2008, 10:59:38 AM2/4/08
to
On Mon, Feb 04, 2008 at 10:10:43AM -0500, Victor Duchovni wrote:
>On Mon, Feb 04, 2008 at 02:57:38PM +0000, scott....@scottrix.co.uk wrote:
>
>> Sorry for being a pain, but I want to get this clear. I can only see two
>> things that could be wrong to get to the problem I am having.
>>
>> 1) Postfix is broken and should be detecting when text/plain attachments
>> have CRLF and not add the CR.
>
>Postfix is an MTA. It is the MUA's responsibility to inject valid content.

Fair enough.

>> 2) My MUA (mutt) is broken and is incorrectly identifying a DOS text
>> file as text/plain when it is not.
>
>The MUA (mutt) is responsible for submitting valid content. What are you
>doing with mutt, and what MIME content is mutt generating? Configure
>mutt to use a custom "sendmail" that just saves the message to a disk
>file. Report what you find in the disk file...

A text file is produced with the email in it, the attachment is text/plain
and the attachment has CRLF for each of it's lines.

It seems the problem is with the MUA (mutt) and I believe that mutt gets
the mime type from libmagic which also reports text/plain for the DOS text
file. It can the tell the difference since "file dos.txt" gives

"ASCII text, with CRLF line terminators"

So I guess I can get it to give a different output for the mimetype too.

Thanks for all your help with this,

Scott.

Victor Duchovni

unread,
Feb 4, 2008, 11:23:26 AM2/4/08
to
On Mon, Feb 04, 2008 at 03:59:38PM +0000, scott....@scottrix.co.uk wrote:

> >The MUA (mutt) is responsible for submitting valid content. What are you
> >doing with mutt, and what MIME content is mutt generating? Configure
> >mutt to use a custom "sendmail" that just saves the message to a disk
> >file. Report what you find in the disk file...
>
> A text file is produced with the email in it, the attachment is text/plain
> and the attachment has CRLF for each of it's lines.

This is wrong. The message must either use CRLF for all message lines
(RFC822 message) or LF for all message lines (unix message file).

> It seems the problem is with the MUA (mutt) and I believe that mutt gets
> the mime type from libmagic which also reports text/plain for the DOS text
> file. It can the tell the difference since "file dos.txt" gives

The MIME type is not the problem, mutt should be stripping the CR when
encoding the text file into a message whose headers and body are LF
terminated.

0 new messages