How to send 7bit mail to certain users when mime headers are missing (are missing headers the problem?)

2008-09-30 Thread rc
My ultimate goal: Send 7bit mail to certain users

I have tried the brute force smtp_never_send_ehlo=yes in the mail.cf and
I have tried the more elegant solution using
master.cf
sevenbit  unix  -   -   n   -   -   smtp
-o smtp_never_send_ehlo=yes

and transport file

Both solutions work as expected if I test them with a mail command
ie: echo test ü | mail [EMAIL PROTECTED]
I get quoted-printable for the designed addresses and 8 bit for the others.

However if I telnet to port 25 it does't work. There is no conversion,
and no mime headers are present or added by Postfix.
I assume postfix relies on proper content-* lines, but through telnet
these here lines are not added and postfix just passes the mail over.

How do I tell Postfix to do 8bit->7bit conversion then?

I have tried some dirty tricks too: like trying (as a first step) to
add  content-type header lines to all outgoing emails with
smtpd_sender_restrictions = regexp:/etc/postfix/access in my main.cf and
/.*/ PREPEND mime-header-example: just an example 8bit to my access file
(for a later postfix 8 to 7 conversion) but nothing is added at all to
the headers.

I am stuck there. Any help greatly appreciated.

Thanks,
RC.


Re: How to send 7bit mail to certain users when mime headers are missing (are missing headers the problem?)

2008-09-30 Thread Wietse Venema
rc:
> My ultimate goal: Send 7bit mail to certain users
> 
> I have tried the brute force smtp_never_send_ehlo=yes in the mail.cf and
> I have tried the more elegant solution using
> master.cf
> sevenbit  unix  -   -   n   -   -   smtp
> -o smtp_never_send_ehlo=yes
> 
> and transport file
> 
> Both solutions work as expected if I test them with a mail command
> ie: echo test ? | mail [EMAIL PROTECTED]
> I get quoted-printable for the designed addresses and 8 bit for the others.

Your mail command creates an 8BITMIME message. Postfix down-grades
it to 7BIT as required by Internet mail RFC documents.

> However if I telnet to port 25 it does't work. There is no conversion,
> and no mime headers are present or added by Postfix.

Postfix does not add MIME headers. That is the job of the mail USER
agent, not the job of the mail TRANSFER agent.

> How do I tell Postfix to do 8bit->7bit conversion then?

MIME conversions are defined only for mail that plays by the rules
of the MIME protocols. So it is your job to provide MIME compliant
messages.

Wietse


Re: How to send 7bit mail to certain users when mime headers are missing (are missing headers the problem?)

2008-09-30 Thread rc
> MIME conversions are defined only for mail that plays by the rules
> of the MIME protocols. So it is your job to provide MIME compliant
> messages.

Wietse,

since I do not have proper access to the application sending these
simple 8bit emails (extended ascii) and I am running a dedicated
postfix relay for them, wouldn't be possible to add a filter to
sanitize those emails (a pipe to formail?) which in turn would return
the mail to postfix for further processing (8->7 bit conversion) and
delivery to the next mail relay?

RC.




2008/9/30 Wietse Venema <[EMAIL PROTECTED]>:
> rc:
>> My ultimate goal: Send 7bit mail to certain users
>>
>> I have tried the brute force smtp_never_send_ehlo=yes in the mail.cf and
>> I have tried the more elegant solution using
>> master.cf
>> sevenbit  unix  -   -   n   -   -   smtp
>> -o smtp_never_send_ehlo=yes
>>
>> and transport file
>>
>> Both solutions work as expected if I test them with a mail command
>> ie: echo test ? | mail [EMAIL PROTECTED]
>> I get quoted-printable for the designed addresses and 8 bit for the others.
>
> Your mail command creates an 8BITMIME message. Postfix down-grades
> it to 7BIT as required by Internet mail RFC documents.
>
>> However if I telnet to port 25 it does't work. There is no conversion,
>> and no mime headers are present or added by Postfix.
>
> Postfix does not add MIME headers. That is the job of the mail USER
> agent, not the job of the mail TRANSFER agent.
>
>> How do I tell Postfix to do 8bit->7bit conversion then?
>
> MIME conversions are defined only for mail that plays by the rules
> of the MIME protocols. So it is your job to provide MIME compliant
> messages.
>
>Wietse
>



-- 
Ariel Sinderman
--
Sinderman IT Solutions
Fürstenrieder Str. 10
80687 München
Email: [EMAIL PROTECTED]
Tel: +49 (174) 56 19 217


Re: How to send 7bit mail to certain users when mime headers are missing (are missing headers the problem?)

2008-09-30 Thread Victor Duchovni
On Tue, Sep 30, 2008 at 04:07:36PM +0200, rc wrote:

> How do I tell Postfix to do 8bit->7bit conversion then?

Postfix only does 8bit->7bit conversion when content is declared to be
8bit. Postfix does not "detect" 8bit content by looking at the characters
in message bodies.

> I have tried some dirty tricks too: like trying (as a first step) to
> add  content-type header lines to all outgoing emails with
> smtpd_sender_restrictions = regexp:/etc/postfix/access in my main.cf and
> /.*/ PREPEND mime-header-example: just an example 8bit to my access file
> (for a later postfix 8 to 7 conversion) but nothing is added at all to
> the headers.

This is too obscure. What are you *actually* doing and why? What is the
actual "8bit" mail that you need to downgrade to 7bit?

Postfix downgrades 8bit content to 7bit content when a non-composite
MIME part (not message/rfc822 or multipart/*) has an explicit
Content-Transfer-Encoding of "8bit".

Without any CTE headers in any leaf MIME parts of the message there will
be no "downgrade". In other words, Postfix downgrades content *declared*
to be 8bit.

-- 
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:


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.


Re: How to send 7bit mail to certain users when mime headers are missing (are missing headers the problem?)

2008-09-30 Thread Wietse Venema
rc:
> > MIME conversions are defined only for mail that plays by the rules
> > of the MIME protocols. So it is your job to provide MIME compliant
> > messages.
> 
> Wietse,
> 
> since I do not have proper access to the application sending these
> simple 8bit emails (extended ascii) and I am running a dedicated
> postfix relay for them, wouldn't be possible to add a filter to
> sanitize those emails (a pipe to formail?) which in turn would return
> the mail to postfix for further processing (8->7 bit conversion) and
> delivery to the next mail relay?

If you run the mail through a program you can make it MIME compliant.

You could trigger a FILTER action on the MAIL FROM sender (in an
smtpd access map) or on some attribute in the message header with
an header_checks map.

Fixing the mail requires headers like:

MIME-Version: 1.0
Content-type: text/plain
Content-transer-encoding: 8bit

Wietse


Re: How to send 7bit mail to certain users when mime headers are missing (are missing headers the problem?)

2008-09-30 Thread Wietse Venema
Wietse Venema:
> rc:
> > > MIME conversions are defined only for mail that plays by the rules
> > > of the MIME protocols. So it is your job to provide MIME compliant
> > > messages.
> > 
> > Wietse,
> > 
> > since I do not have proper access to the application sending these
> > simple 8bit emails (extended ascii) and I am running a dedicated
> > postfix relay for them, wouldn't be possible to add a filter to
> > sanitize those emails (a pipe to formail?) which in turn would return
> > the mail to postfix for further processing (8->7 bit conversion) and
> > delivery to the next mail relay?
> 
> If you run the mail through a program you can make it MIME compliant.
> 
> You could trigger a FILTER action on the MAIL FROM sender (in an
> smtpd access map) or on some attribute in the message header with
> an header_checks map.
> 
> Fixing the mail requires headers like:
> 
> MIME-Version: 1.0
> Content-type: text/plain
> Content-transer-encoding: 8bit

Make that: Content-transfer-encoding

>   Wietse
> 
> 



Re: How to send 7bit mail to certain users when mime headers are missing (are missing headers the problem?)

2008-10-01 Thread rc
> Fixing the mail requires headers like:
>
> MIME-Version: 1.0
> Content-type: text/plain
> Content-transer-encoding: 8bit
>
>Wietse

It is working now. I fixed the header externally with formail (can't
Postfix do that without external help?)
I post my solution here for future references. Also any suggestions
for improvements are welcome.

#master.cf
smtp  inet  n   -   n   -   -   smtpd
 -o content_filter=filter:dummy
sevenbit  unix  -   -   n   -   -   smtp
-o smtp_never_send_ehlo=yes
filterunix  -   n   n   -   10  pipe
  flags=Rq user=nobody argv=/path/to/my.filter -f ${sender} -- ${recipient}
###

#transport
[EMAIL PROTECTED] sevenbit:[my.relayhost]
[EMAIL PROTECTED] sevenbit:[my.relayhost]
[EMAIL PROTECTED] sevenbit:[my.relayhost]
[EMAIL PROTECTED] sevenbit:[my.relayhost]

###

#!/bin/sh
# my.filter

# Meant to be invoked as follows: /path/to/my.filter -f sender recipients

INSPECT_DIR=/tmp/filter

SENDMAIL="/usr/sbin/sendmail -i" # NEVER NEVER NEVER use "-t" here.

# Exit codes from 
EX_TEMPFAIL=75
EX_UNAVAILABLE=69

# Clean up when done or when aborting.
trap "rm -f in.$$" 0 1 2 3 15

# Start processing.

mkdir -p $INSPECT_DIR

cd $INSPECT_DIR || {
echo $INSPECT_DIR does not exist; exit $EX_TEMPFAIL; }

cat >in.$$ || {
echo Cannot save mail to file; exit $EX_TEMPFAIL; }

# Specify your content filter here.

formail -a "MIME-Version: 1.0" -a "Content-Type: text/plain;
charset=utf-8" -a "Content-Transfer-Encoding: 8bit"  out.$$ ||
{
   echo Message content rejected; exit $EX_UNAVAILABLE; }

$SENDMAIL "$@" 

Re: How to send 7bit mail to certain users when mime headers are missing (are missing headers the problem?)

2008-10-01 Thread Wietse Venema
rc:
> > Fixing the mail requires headers like:
> >
> > MIME-Version: 1.0
> > Content-type: text/plain
> > Content-transer-encoding: 8bit
> >
> >Wietse
> 
> It is working now. I fixed the header externally with formail (can't
> Postfix do that without external help?)

It's the job of MUAs, mail applications, etc. to inject correctly
formatted mail into the email infrastructure. It's not the job of
an MTA to make arbitary content standards-compliant.

> I post my solution here for future references. Also any suggestions
> for improvements are welcome.
> 
> #master.cf
> smtp  inet  n   -   n   -   -   smtpd
>  -o content_filter=filter:dummy
> sevenbit  unix  -   -   n   -   -   smtp
> -o smtp_never_send_ehlo=yes
> filterunix  -   n   n   -   10  pipe
>   flags=Rq user=nobody argv=/path/to/my.filter -f ${sender} -- ${recipient}
> ###
> 
> #transport
> [EMAIL PROTECTED] sevenbit:[my.relayhost]
> [EMAIL PROTECTED] sevenbit:[my.relayhost]
> [EMAIL PROTECTED] sevenbit:[my.relayhost]
> [EMAIL PROTECTED] sevenbit:[my.relayhost]

I recommend that you run ALL mail FROM this application through
the filter so that it is always MIME compliant.

Once it is MIME compliant you can configure Postfix to always ignore
8BITMIME announcements so it converts all mail to 7bit encoding.

Or you can rely on automatic conversion when an 8BITMIME compliant
MTA (such as Postfix) sends mail to a non-8BITMIME mail server.

Wietse


Re: How to send 7bit mail to certain users when mime headers are missing (are missing headers the problem?)

2008-10-01 Thread mouss

rc wrote:

Fixing the mail requires headers like:

MIME-Version: 1.0
Content-type: text/plain
Content-transer-encoding: 8bit

   Wietse


It is working now. I fixed the header externally with formail (can't
Postfix do that without external help?)


what _you_ mean and what _I_ mean are different. the only way to handle 
this is follow a standard or use per-user tools.



[snip]



Re: How to send 7bit mail to certain users when mime headers are missing (are missing headers the problem?)

2008-10-01 Thread rc
>> It is working now. I fixed the header externally with formail (can't
>> Postfix do that without external help?)
>
> It's the job of MUAs, mail applications, etc. to inject correctly
> formatted mail into the email infrastructure. It's not the job of
> an MTA to make arbitary content standards-compliant.

I know I am not using Postfix (in this specific machine) as originally
intended by its developers (to be an MTA), but I found it is an
appropriate tool (to be an email converter from non compliant to
compliant) in my situation since I have an application (black box)
injecting mime-less emails into my email infrastructure.

I have no problems using Postfix and an external filter (formail), but
I imagine a more efficient solution would have been to let Postfix add
those headers itself (a feature Postfix has) and on a second pass
behave like a normal MTA.

> > #transport
> > [EMAIL PROTECTED] sevenbit:[my.relayhost]
> > [EMAIL PROTECTED] sevenbit:[my.relayhost]
> > [EMAIL PROTECTED] sevenbit:[my.relayhost]
> > [EMAIL PROTECTED] sevenbit:[my.relayhost]

> I recommend that you run ALL mail FROM this application through
> the filter so that it is always MIME compliant.

Yes, that is exactly what I am doing on the first pass with formail.
This transport is only used on the second pass to convert to 7 bit
only email to certain destinations (the infamous Exchange 5 bug)
There is no way then to remove :[my.relayhost] from these entries and
let it use the one configured in main.cf?

Thanks,
RC.


Re: How to send 7bit mail to certain users when mime headers are missing (are missing headers the problem?)

2008-10-02 Thread Wietse Venema
rc:
> > > #transport
> > > [EMAIL PROTECTED] sevenbit:[my.relayhost]
> > > [EMAIL PROTECTED] sevenbit:[my.relayhost]
> > > [EMAIL PROTECTED] sevenbit:[my.relayhost]
> > > [EMAIL PROTECTED] sevenbit:[my.relayhost]
> 
> > I recommend that you run ALL mail FROM this application through
> > the filter so that it is always MIME compliant.
> 
> Yes, that is exactly what I am doing on the first pass with formail.
> This transport is only used on the second pass to convert to 7 bit
> only email to certain destinations (the infamous Exchange 5 bug)
> There is no way then to remove :[my.relayhost] from these entries and
> let it use the one configured in main.cf?

Yes. If sevenbit: ignores 8BITMIME announcements in EHLO replies,
then you don't need to override the recipient domain with
[my.relayhost].

Wietse


Re: How to send 7bit mail to certain users when mime headers are missing (are missing headers the problem?)

2008-10-02 Thread Wietse Venema
Wietse Venema:
> rc:
> > > > #transport
> > > > [EMAIL PROTECTED] sevenbit:[my.relayhost]
> > > > [EMAIL PROTECTED] sevenbit:[my.relayhost]
> > > > [EMAIL PROTECTED] sevenbit:[my.relayhost]
> > > > [EMAIL PROTECTED] sevenbit:[my.relayhost]
> > 
> > > I recommend that you run ALL mail FROM this application through
> > > the filter so that it is always MIME compliant.
> > 
> > Yes, that is exactly what I am doing on the first pass with formail.
> > This transport is only used on the second pass to convert to 7 bit
> > only email to certain destinations (the infamous Exchange 5 bug)
> > There is no way then to remove :[my.relayhost] from these entries and
> > let it use the one configured in main.cf?
> 
> Yes. If sevenbit: ignores 8BITMIME announcements in EHLO replies,
> then you don't need to override the recipient domain with
> [my.relayhost].

Moreover, you can safely omit the user@ portions in your transport
map entries, because the "infamous Exchange 5 bug" (*) will happen
with all recipients that have the same domain.

Wietse

(*) Actually the behavior to bounce-instead-of-convert is legitimized
by the MIME RFCs, but we all know how politics tend to take
precedence over correctness.


Re: How to send 7bit mail to certain users when mime headers are missing (are missing headers the problem?)

2008-10-02 Thread rc
> Moreover, you can safely omit the user@ portions in your transport
> map entries, because the "infamous Exchange 5 bug" (*) will happen
> with all recipients that have the same domain.

I thought so at the beginning too. But this domain is spread in many
countries and every country having its own MTA. Only one of these MTAs
is the offender, but all users are behind the same domain.com.

Off the record, I have succeeded adding the mime lines with Postfix using:

# header_checks
/^Date/ PREPEND MIME-Version: 1.0^MContent-Type:
text/plain^MContent-Transfer-Encoding: 8bit

But again, like the 7bit conversion, it is only working if the header
is already mime compliant.
So it is of no use, I'll stick with formail as filter.

RC.


Re: How to send 7bit mail to certain users when mime headers are missing (are missing headers the problem?)

2008-10-02 Thread Victor Duchovni
On Thu, Oct 02, 2008 at 03:36:58PM +0200, rc wrote:

> # header_checks
> /^Date/ PREPEND MIME-Version: 1.0^MContent-Type: 
> text/plain^MContent-Transfer-Encoding: 8bit

I've seen no documentation of support for PREPENDING multiple headers
in this fashion. It should not work, unless something downstream treats
CR as a line terminator for RFC 822/2822/5322 content.

-- 
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:


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.