Loading ...
Sorry, an error occurred while loading the content.

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

Expand Messages
  • 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
    Message 1 of 14 , Sep 30, 2008
    • 0 Attachment
      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 myaddress@...
      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.
    • Wietse Venema
      ... Your mail command creates an 8BITMIME message. Postfix down-grades it to 7BIT as required by Internet mail RFC documents. ... Postfix does not add MIME
      Message 2 of 14 , Sep 30, 2008
      • 0 Attachment
        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 myaddress@...
        > 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
      • rc
        ... 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
        Message 3 of 14 , Sep 30, 2008
        • 0 Attachment
          > 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 <wietse@...>:
          > 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 myaddress@...
          >> 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: info@...
          Tel: +49 (174) 56 19 217
        • Victor Duchovni
          ... 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
          Message 4 of 14 , Sep 30, 2008
          • 0 Attachment
            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:
            <mailto:majordomo@...?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.
          • Wietse Venema
            ... 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
            Message 5 of 14 , Sep 30, 2008
            • 0 Attachment
              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
            • Wietse Venema
              ... Make that: Content-transfer-encoding
              Message 6 of 14 , Sep 30, 2008
              • 0 Attachment
                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
                >
                >
              • rc
                ... 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.
                Message 7 of 14 , Oct 1, 2008
                • 0 Attachment
                  > 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
                  filter unix - n n - 10 pipe
                  flags=Rq user=nobody argv=/path/to/my.filter -f ${sender} -- ${recipient}
                  ###############################

                  #transport
                  some1@... sevenbit:[my.relayhost]
                  some2@... sevenbit:[my.relayhost]
                  some3@... sevenbit:[my.relayhost]
                  some4@... 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 <sysexits.h>
                  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" <in.$$ > out.$$ ||
                  {
                  echo Message content rejected; exit $EX_UNAVAILABLE; }

                  $SENDMAIL "$@" <out.$$

                  exit $?

                  ##########################################
                  2 doubts

                  -When some@... is matched the conversion occurs,
                  Content-Transfer-Encoding becomes quoted-printable as expected, but
                  Content-Type is not changed (charset=utf-8 stays there). I guess this
                  is innocuous.

                  -As seen above, in my transport file I do need to specify my relayhost
                  in every line or otherwise mail is delivered locally. I should not be
                  required to set again since it is already in main.cf. Am I doing
                  something wrong? I presume I might need a minor change in the
                  master.cf


                  Once this is polished I will try to use the advanced content filter
                  solution using a second port.

                  Thanks, RC.
                • Wietse Venema
                  ... 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
                  Message 8 of 14 , Oct 1, 2008
                  • 0 Attachment
                    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
                    > filter unix - n n - 10 pipe
                    > flags=Rq user=nobody argv=/path/to/my.filter -f ${sender} -- ${recipient}
                    > ###############################
                    >
                    > #transport
                    > some1@... sevenbit:[my.relayhost]
                    > some2@... sevenbit:[my.relayhost]
                    > some3@... sevenbit:[my.relayhost]
                    > some4@... 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
                  • mouss
                    ... what _you_ mean and what _I_ mean are different. the only way to handle this is follow a standard or use per-user tools.
                    Message 9 of 14 , Oct 1, 2008
                    • 0 Attachment
                      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]
                      >
                    • rc
                      ... 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
                      Message 10 of 14 , Oct 1, 2008
                      • 0 Attachment
                        >> 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
                        > > some1@... sevenbit:[my.relayhost]
                        > > some2@... sevenbit:[my.relayhost]
                        > > some3@... sevenbit:[my.relayhost]
                        > > some4@... 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.
                      • Wietse Venema
                        ... Yes. If sevenbit: ignores 8BITMIME announcements in EHLO replies, then you don t need to override the recipient domain with [my.relayhost]. Wietse
                        Message 11 of 14 , Oct 2, 2008
                        • 0 Attachment
                          rc:
                          > > > #transport
                          > > > some1@... sevenbit:[my.relayhost]
                          > > > some2@... sevenbit:[my.relayhost]
                          > > > some3@... sevenbit:[my.relayhost]
                          > > > some4@... 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
                        • Wietse Venema
                          ... Moreover, you can safely omit the user@ portions in your transport map entries, because the infamous Exchange 5 bug (*) will happen with all recipients
                          Message 12 of 14 , Oct 2, 2008
                          • 0 Attachment
                            Wietse Venema:
                            > rc:
                            > > > > #transport
                            > > > > some1@... sevenbit:[my.relayhost]
                            > > > > some2@... sevenbit:[my.relayhost]
                            > > > > some3@... sevenbit:[my.relayhost]
                            > > > > some4@... 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.
                          • rc
                            ... 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
                            Message 13 of 14 , Oct 2, 2008
                            • 0 Attachment
                              > 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.
                            • Victor Duchovni
                              ... 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
                              Message 14 of 14 , Oct 2, 2008
                              • 0 Attachment
                                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:
                                <mailto:majordomo@...?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.
                              Your message has been successfully submitted and would be delivered to recipients shortly.