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

How to deal with erroneous Return-Paths?

Expand Messages
  • Michael Neurohr
    Hi, the German Free Mailer GMX sends its newsletters with a Return-Path like #16155204@gmx.net . When I pass the message to Procmail with
    Message 1 of 6 , Jun 11, 2014
    • 0 Attachment
      Hi,
      the German Free Mailer GMX sends its newsletters with a Return-Path
      like "#16155204@...".

      When I pass the message to Procmail with
      =====================================================================
      procmail unix - n n - 10 pipe
      flags=Rq user=vmail null_sender= argv=/usr/bin/procmail -m
      E_SENDER=$sender E_RECIPIENT=$recipient /etc/procmailrc
      =====================================================================
      the "$sender" stays empty because of the leading "#".

      I also recognized that sometimes the sending mail server does not
      provide a Return-Path at all.

      These cases result in Sendmail not being able to reinject the mail after
      Procmail has processed the message.
      How can I handle such cases? You can find my procmailrc at [1].

      The corresponding log lines are:

      /var/log/maillog
      =====================================================================
      Jun 12 07:39:15 mx0 postfix/smtpd[13440]: connect from
      mout.gmx.net[212.227.15.19]
      Jun 12 07:39:15 mx0 postfix/smtpd[13440]: B689B8240481:
      client=mout.gmx.net[212.227.15.19]
      Jun 12 07:39:15 mx0 postfix/cleanup[13447]: B689B8240481:
      message-id=<08f52951b1ef360622acf42743d2d5ae@...-portal.com>
      Jun 12 07:39:15 mx0 postfix/qmgr[26217]: B689B8240481:
      from=<#16155204@...>, size=13755, nrcpt=1 (queue active)
      Jun 12 07:39:15 mx0 postfix/smtpd[13440]: disconnect from
      mout.gmx.net[212.227.15.19]
      Jun 12 07:39:24 mx0 postfix/sendmail[13474]: fatal: Recipient addresses
      must be specified on the command line or via the -t option
      Jun 12 07:39:24 mx0 postfix/postdrop[13475]: warning: stdin: unexpected
      EOF in data, record type 78 length 62
      Jun 12 07:39:24 mx0 postfix/postdrop[13475]: fatal: uid=5000: malformed
      input
      Jun 12 07:39:24 mx0 postfix/pipe[13448]: B689B8240481:
      to=<michael@...>, relay=procmail, delay=9.1,
      delays=0.08/0.01/0/9, dsn=5.2.0, status=bounced (can't create user
      output file)
      Jun 12 07:39:24 mx0 postfix/cleanup[13447]: CC9D58243806:
      message-id=<20140612053924.CC9D58243806@...>
      Jun 12 07:39:24 mx0 postfix/qmgr[26217]: CC9D58243806: from=<>,
      size=15587, nrcpt=1 (queue active)
      Jun 12 07:39:24 mx0 postfix/bounce[13476]: B689B8240481: sender
      non-delivery notification: CC9D58243806
      Jun 12 07:39:24 mx0 postfix/qmgr[26217]: B689B8240481: removed
      Jun 12 07:39:25 mx0 postfix/smtp[13482]: CC9D58243806:
      to=<#16155204@...>, relay=mx00.emig.gmx.net[213.165.67.114]:25,
      delay=0.44, delays=0.01/0.01/0.17/0.24, dsn=5.0.0, status=bounced (host
      mx00.emig.gmx.net[213.165.67.114] said: 550 Requested action not taken:
      mailbox unavailable (in reply to RCPT TO command))
      Jun 12 07:39:25 mx0 postfix/qmgr[26217]: CC9D58243806: removed
      =====================================================================

      /var/log/procmail
      =====================================================================
      procmail: [13449] Thu Jun 12 07:39:15 2014
      procmail: Locking "/var/mail/vhosts/backup-mail/michael@.../.lock"
      procmail: Assigning
      "LASTFOLDER=/var/mail/vhosts/backup-mail/michael@.../new/1402551555.13449_1.mx0.ovz"
      procmail: Unlocking
      "/var/mail/vhosts/backup-mail/michael@.../.lock"
      procmail: Executing "/usr/local/bin/clamassassin"
      procmail: Match on "^X-Virus-Status: No"
      procmail: Executing "/usr/bin/spamassassin"
      procmail: [13449] Thu Jun 12 07:39:24 2014
      procmail: Executing "/usr/sbin/sendmail,-f,michael@..."
      sendmail: fatal: Recipient addresses must be specified on the command
      line or via the -t option
      procmail: [13449] Thu Jun 12 07:39:24 2014
      procmail: Program failure (75) of "/usr/sbin/sendmail"
      procmail: Assigning "LASTFOLDER=/usr/sbin/sendmail -f michael@..."
      Subject: Exklusiver Shopping-Zugang: Mode bis zu 80% reduziert - mit
      Gutschein
      Folder: **Bounced** 13945
      postdrop: warning: stdin: unexpected EOF in data, record type 78 length 62
      postdrop: fatal: uid=5000: malformed input
      =====================================================================

      Cheers,
      Michael

      [1] http://marc.info/?l=postfix-users&m=140247232114778&w=2
    • Wietse Venema
      ... The Return-Path: header is CREATED upon final delivery. The Return-Path: header is IGNORED while receiving mail. The value in the Return-Path: header is
      Message 2 of 6 , Jun 12, 2014
      • 0 Attachment
        Michael Neurohr:
        > Hi,
        > the German Free Mailer GMX sends its newsletters with a Return-Path
        > like "#16155204@...".
        > I also recognized that sometimes the sending mail server does not
        > provide a Return-Path at all.

        The Return-Path: header is CREATED upon final delivery.

        The Return-Path: header is IGNORED while receiving mail.

        The value in the Return-Path: header is the envelope sender address
        (see Wikipedia), i.e. the address in the MAIL FROM command during
        an SMTP session.

        If you use mail software that mis-handles addresses such as
        "#16155204@..." then you need to use better mail software.

        In the address local-part, the "#" character is not special according
        to RFC 5321, the SMTP mail standard, or RFC 5322, the Internet
        message standard.

        Wietse
      • Michael Neurohr
        ... The point is, that I m passing the mail from Postfix with the command /usr/bin/procmail -m E_SENDER=${sender} E_RECIPIENT=${recipient} /etc/procmailrc to
        Message 3 of 6 , Jun 12, 2014
        • 0 Attachment
          On 12.06.2014 13:19, Wietse Venema wrote:
          > If you use mail software that mis-handles addresses such as
          > "#16155204@..." then you need to use better mail software.

          The point is, that I'm passing the mail from Postfix with the command

          /usr/bin/procmail -m E_SENDER=${sender} E_RECIPIENT=${recipient}
          /etc/procmailrc

          to procmail.

          After processing with procmail I'm injecting the mail back to Postfix
          with the command

          | /usr/sbin/sendmail -i -f $E_SENDER $E_RECIPIENT



          The problem now is, that if the variable "E_SENDER" is empty or contains
          "#", Procmail passes an empty variable to Sendmail which causes Sendmail
          to fail.

          Is it the correct way at all to pass the envelope sender address that I
          got from Postfix back to Sendmail after processing with Procmail, or
          should I rather do something different?

          Thanks,
          Michael
        • Wietse Venema
          ... And because procmail mis-handles #16155204@gmx.net , you are on the wrong mailing list to complain about that. Wietse
          Message 4 of 6 , Jun 12, 2014
          • 0 Attachment
            Michael Neurohr:
            > On 12.06.2014 13:19, Wietse Venema wrote:
            > > If you use mail software that mis-handles addresses such as
            > > "#16155204@..." then you need to use better mail software.
            >
            > The point is, that I'm passing the mail from Postfix with the command
            > /usr/bin/procmail -m E_SENDER=${sender} E_RECIPIENT=${recipient} /etc/procmailrc
            > to procmail.

            And because procmail mis-handles "#16155204@...", you are on the
            wrong mailing list to complain about that.

            Wietse
          • Michael Neurohr
            Although it s not a Postfix problem, I d like to share the solution just for completeness in the hope it might be useful. Instead of setting sender and
            Message 5 of 6 , Jun 12, 2014
            • 0 Attachment
              Although it's not a Postfix problem, I'd like to share the solution just
              for completeness in the hope it might be useful.

              Instead of setting sender and recipient as parameters, one should
              forward it as arguments.

              The whole thing now looks as follows:

              The filter definition in Postfix' master.cf:
              =====================================================================
              procmail unix - n n - 10 pipe
              flags=Rq user=vmail null_sender= argv=/usr/bin/procmail -m
              /etc/procmailrc ${sender} ${recipient} ${domain}
              =====================================================================
              Whereas the "q" at flags is very important to get it working.

              The /etc/procmailrc contains:
              =====================================================================
              SHELL=/bin/sh
              E_SENDER=$1
              E_RECIPIENT=$2
              ER_DOMAIN=$3
              SENDMAILFLAGS="-i -f $E_SENDER $E_RECIPIENT"
              LOGFILE="/var/log/procmail"
              VERBOSE=on

              # First make a backup of the mail
              :0c:
              /var/mail/vhosts/backup-mail/$E_RECIPIENT/

              # Scan for viruses
              :0fw
              | /usr/local/bin/clamassassin

              # If no virus has been found, scan for Spam
              :0fw
              * ^X-Virus-Status: No
              | /usr/bin/spamassassin

              :0w
              * !E_SENDER ?? (.)
              | /usr/sbin/sendmail -i -f noreplay@$ER_DOMAIN $E_RECIPIENT

              # Last action: inject back to Postfix
              :0w
              | /usr/sbin/sendmail $SENDMAILFLAGS
              =====================================================================

              E_SENDER=$1, E_RECIPIENT=$2 and ER_DOMAIN=$3 are assigning the command
              line arguments.

              "* !E_SENDER ?? (.)" checks if the variable "E_SENDER" is empty. If it
              is empty, we need to adopt the Sendmail command.

              If "!E_SENDER ?? (.)" evaluates to true, the Procmail execution ends
              after invoking Sendmail, otherwise it executes the last action.

              HTH,
              Michael
            • Wietse Venema
              ... WARNING: THIS WILL LOSE MAIL when the message has more than one recipient. You must specify procmail_destination_recipient_limit=1 in main.cf. Wietse
              Message 6 of 6 , Jun 12, 2014
              • 0 Attachment
                Michael Neurohr:
                > Although it's not a Postfix problem, I'd like to share the solution just
                > for completeness in the hope it might be useful.
                >
                > Instead of setting sender and recipient as parameters, one should
                > forward it as arguments.
                >
                > The whole thing now looks as follows:
                >
                > The filter definition in Postfix' master.cf:
                > =====================================================================
                > procmail unix - n n - 10 pipe
                > flags=Rq user=vmail null_sender= argv=/usr/bin/procmail -m
                > /etc/procmailrc ${sender} ${recipient} ${domain}

                ...
                > ER_DOMAIN=$3
                > SENDMAILFLAGS="-i -f $E_SENDER $E_RECIPIENT"

                WARNING: THIS WILL LOSE MAIL when the message has more than one recipient.
                You must specify "procmail_destination_recipient_limit=1" in main.cf.

                Wietse

                Quote 1 from pipe(8) manpage:

                SINGLE-RECIPIENT DELIVERY
                Some destinations cannot handle more than one recipient per delivery
                request. Examples are pagers or fax machines. In addition, multi-
                recipient delivery is undesirable when prepending a Delivered-to: or X-
                Original-To: message header.

                To prevent Postfix from sending multiple recipients per delivery
                request, specify

                transport_destination_recipient_limit = 1

                in the Postfix main.cf file, where transport is the name in the first
                column of the Postfix master.cf entry for the pipe-based delivery
                transport.

                Quote 2 from the pipe(8) manpage:

                ${recipient}
                This macro expands to the complete recipient address.

                A command-line argument that contains ${recipient}
                expands to as many command-line arguments as there are
                recipients.

                Presumably, this also applies to the ${domain} expansion.
              Your message has been successfully submitted and would be delivered to recipients shortly.