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

How to rewrite email when sent

Expand Messages
  • tmac
    I have a local host configured to relay through a mailhost. There is a local user (call it test) that I want all the email sent to me (tmac) in other words,
    Message 1 of 5 , Jan 24, 2013
    • 0 Attachment
      I have a local host configured to relay through a mailhost.
      There is a local user (call it test) that I want all the email sent to me (tmac)

      in other words, any email sent to
      test@... (or test@...) should go to tmac@...

      I have tried relocated users, but it does not seem to be working.
      Is there a better (working) solution with postfix without having to
      deal with .forward files?
    • Noel Jones
      ... Use virtual_alias_maps to redirect mail. # virtual_alias test@local.example tmac@example.com Run postmap virtual_alias after editing that file. #
      Message 2 of 5 , Jan 24, 2013
      • 0 Attachment
        On 1/24/2013 6:42 AM, tmac wrote:
        > I have a local host configured to relay through a mailhost.
        > There is a local user (call it test) that I want all the email sent to me (tmac)
        >
        > in other words, any email sent to
        > test@... (or test@...) should go to tmac@...
        >
        > I have tried relocated users, but it does not seem to be working.
        > Is there a better (working) solution with postfix without having to
        > deal with .forward files?
        >

        Use virtual_alias_maps to redirect mail.

        # virtual_alias
        test@... tmac@...

        Run "postmap virtual_alias" after editing that file.

        # main.cf
        virtual_alias_maps = hash:/etc/postfix/virtual_alias

        Run "postfix reload" after editing main.cf


        http://www.postfix.org/ADDRESS_REWRITING_README.html#virtual
        http://www.postfix.org/postconf.5.html#virtual_alias_maps



        -- Noel Jones
      • tmac
        Excellent! Thanks. I just did this on my mail relay and it works. I did manage to get it to work a few moments ago with canonical_maps also. Now, what about a
        Message 3 of 5 , Jan 24, 2013
        • 0 Attachment
          Excellent! Thanks. I just did this on my mail relay and it works.
          I did manage to get it to work a few moments ago with canonical_maps also.

          Now, what about a step further?

          I have a a number of systems (under NIS) with the same user. When they
          generate email,
          is goes to myuser@... where myusr and mydomain are the same, but
          the host portion is different. is there a way to collapse say:

          test@... tmac@...
          test@... tmac@...
          test@... tmac@...

          into a single line? i.e. wildcard it some how
          I have not found any working examples of a wildcard in the "host"
          position above.

          Thanks


          --tmac


          On Thu, Jan 24, 2013 at 7:56 AM, Noel Jones <njones@...> wrote:
          > On 1/24/2013 6:42 AM, tmac wrote:
          >> I have a local host configured to relay through a mailhost.
          >> There is a local user (call it test) that I want all the email sent to me (tmac)
          >>
          >> in other words, any email sent to
          >> test@... (or test@...) should go to tmac@...
          >>
          >> I have tried relocated users, but it does not seem to be working.
          >> Is there a better (working) solution with postfix without having to
          >> deal with .forward files?
          >>
          >
          > Use virtual_alias_maps to redirect mail.
          >
          > # virtual_alias
          > test@... tmac@...
          >
          > Run "postmap virtual_alias" after editing that file.
          >
          > # main.cf
          > virtual_alias_maps = hash:/etc/postfix/virtual_alias
          >
          > Run "postfix reload" after editing main.cf
          >
          >
          > http://www.postfix.org/ADDRESS_REWRITING_README.html#virtual
          > http://www.postfix.org/postconf.5.html#virtual_alias_maps
          >
          >
          >
          > -- Noel Jones
        • Jeroen Geilman
          ... You can use a regex or PCRE map: /etc/postfix/pcre-virtual: /^test@[^.]+ .example$/ tmac@example.com These maps types are not postmap ed. -- J.
          Message 4 of 5 , Jan 24, 2013
          • 0 Attachment
            On 01/24/2013 02:43 PM, tmac wrote:
            > Excellent! Thanks. I just did this on my mail relay and it works.
            > I did manage to get it to work a few moments ago with canonical_maps also.
            >
            > Now, what about a step further?
            >
            > I have a a number of systems (under NIS) with the same user. When they
            > generate email,
            > is goes to myuser@... where myusr and mydomain are the same, but
            > the host portion is different. is there a way to collapse say:
            >
            > test@... tmac@...
            > test@... tmac@...
            > test@... tmac@...
            >
            > into a single line? i.e. wildcard it some how
            > I have not found any working examples of a wildcard in the "host"
            > position above.

            You can use a regex or PCRE map:

            /etc/postfix/pcre-virtual:

            /^test@[^.]+\.example$/ tmac@...

            These maps types are not postmap'ed.


            --
            J.
          • tmac
            awesome...thanks...I had flubbed my regex that I was trying.. --tmac
            Message 5 of 5 , Jan 24, 2013
            • 0 Attachment
              awesome...thanks...I had flubbed my regex that I was trying..

              --tmac





              On Thu, Jan 24, 2013 at 9:39 AM, Jeroen Geilman <jeroen@...> wrote:
              > On 01/24/2013 02:43 PM, tmac wrote:
              >>
              >> Excellent! Thanks. I just did this on my mail relay and it works.
              >> I did manage to get it to work a few moments ago with canonical_maps also.
              >>
              >> Now, what about a step further?
              >>
              >> I have a a number of systems (under NIS) with the same user. When they
              >> generate email,
              >> is goes to myuser@... where myusr and mydomain are the same, but
              >> the host portion is different. is there a way to collapse say:
              >>
              >> test@... tmac@...
              >> test@... tmac@...
              >> test@... tmac@...
              >>
              >> into a single line? i.e. wildcard it some how
              >> I have not found any working examples of a wildcard in the "host"
              >> position above.
              >
              >
              > You can use a regex or PCRE map:
              >
              > /etc/postfix/pcre-virtual:
              >
              > /^test@[^.]+\.example$/ tmac@...
              >
              > These maps types are not postmap'ed.
              >
              >
              > --
              > J.
              >
            Your message has been successfully submitted and would be delivered to recipients shortly.