Postfix rewriting subject for specific addresses

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












3















I would like to add a tag to all email messages sent to a particular address. I have tried to copy examples from the web, but can't seem to get it working.



Here's what I've done so far:




  1. Add to /etc/postfix/transport



    email@example.com rewrite:



  2. Add to /etc/postfix/master.cf



    rewrite unix - - n - - smtp
    -o header_checks=pcre:/etc/postfix/rewrite_headers



  3. Create /etc/postfix/rewrite_headers containing



    /^Subject: (.+)$/i REPLACE Subject: [Example tag] $1


Where am I going wrong?










share|improve this question




























    3















    I would like to add a tag to all email messages sent to a particular address. I have tried to copy examples from the web, but can't seem to get it working.



    Here's what I've done so far:




    1. Add to /etc/postfix/transport



      email@example.com rewrite:



    2. Add to /etc/postfix/master.cf



      rewrite unix - - n - - smtp
      -o header_checks=pcre:/etc/postfix/rewrite_headers



    3. Create /etc/postfix/rewrite_headers containing



      /^Subject: (.+)$/i REPLACE Subject: [Example tag] $1


    Where am I going wrong?










    share|improve this question


























      3












      3








      3


      1






      I would like to add a tag to all email messages sent to a particular address. I have tried to copy examples from the web, but can't seem to get it working.



      Here's what I've done so far:




      1. Add to /etc/postfix/transport



        email@example.com rewrite:



      2. Add to /etc/postfix/master.cf



        rewrite unix - - n - - smtp
        -o header_checks=pcre:/etc/postfix/rewrite_headers



      3. Create /etc/postfix/rewrite_headers containing



        /^Subject: (.+)$/i REPLACE Subject: [Example tag] $1


      Where am I going wrong?










      share|improve this question
















      I would like to add a tag to all email messages sent to a particular address. I have tried to copy examples from the web, but can't seem to get it working.



      Here's what I've done so far:




      1. Add to /etc/postfix/transport



        email@example.com rewrite:



      2. Add to /etc/postfix/master.cf



        rewrite unix - - n - - smtp
        -o header_checks=pcre:/etc/postfix/rewrite_headers



      3. Create /etc/postfix/rewrite_headers containing



        /^Subject: (.+)$/i REPLACE Subject: [Example tag] $1


      Where am I going wrong?







      email postfix






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 9 at 8:55









      Rui F Ribeiro

      41.6k1483141




      41.6k1483141










      asked Dec 29 '15 at 17:52









      James ShieldsJames Shields

      14616




      14616




















          1 Answer
          1






          active

          oldest

          votes


















          1














          You should be able to do this without a custom transport, using built-in header checks.



          Add to main.cf:



          header_checks = pcre:/etc/postfix/rewrite_headers


          Your rewrite_headers file will have the existing rule wrapped in a conditional:



          if /^To: email@example.com$/i
          /^Subject: (.+)$/i REPLACE Subject: [Example tag] $1
          endif


          This should handle everything without the need for a transport config.






          share|improve this answer

























          • Is this also going to work if I want to change the sender of the mail for specific recipients?

            – wie5Ooma
            Jan 19 '18 at 22:46











          • Thanks for the tips. Unfortunately for me, my postfix config doesn't work as per documentation. header_checks doc says the header is checked in one bunch, not line by line. But this doesn't work accordingly to my config. So your tip doesn't work on my config.

            – Luc-Olivier
            May 25 '18 at 14:54











          • There was a mistake in my config example. header_checks was set to a file path, but as it contains regex rules the path needs to be prefixed with pcre:

            – Murphy's Prophet
            Jun 9 '18 at 2:37










          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f252193%2fpostfix-rewriting-subject-for-specific-addresses%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          You should be able to do this without a custom transport, using built-in header checks.



          Add to main.cf:



          header_checks = pcre:/etc/postfix/rewrite_headers


          Your rewrite_headers file will have the existing rule wrapped in a conditional:



          if /^To: email@example.com$/i
          /^Subject: (.+)$/i REPLACE Subject: [Example tag] $1
          endif


          This should handle everything without the need for a transport config.






          share|improve this answer

























          • Is this also going to work if I want to change the sender of the mail for specific recipients?

            – wie5Ooma
            Jan 19 '18 at 22:46











          • Thanks for the tips. Unfortunately for me, my postfix config doesn't work as per documentation. header_checks doc says the header is checked in one bunch, not line by line. But this doesn't work accordingly to my config. So your tip doesn't work on my config.

            – Luc-Olivier
            May 25 '18 at 14:54











          • There was a mistake in my config example. header_checks was set to a file path, but as it contains regex rules the path needs to be prefixed with pcre:

            – Murphy's Prophet
            Jun 9 '18 at 2:37















          1














          You should be able to do this without a custom transport, using built-in header checks.



          Add to main.cf:



          header_checks = pcre:/etc/postfix/rewrite_headers


          Your rewrite_headers file will have the existing rule wrapped in a conditional:



          if /^To: email@example.com$/i
          /^Subject: (.+)$/i REPLACE Subject: [Example tag] $1
          endif


          This should handle everything without the need for a transport config.






          share|improve this answer

























          • Is this also going to work if I want to change the sender of the mail for specific recipients?

            – wie5Ooma
            Jan 19 '18 at 22:46











          • Thanks for the tips. Unfortunately for me, my postfix config doesn't work as per documentation. header_checks doc says the header is checked in one bunch, not line by line. But this doesn't work accordingly to my config. So your tip doesn't work on my config.

            – Luc-Olivier
            May 25 '18 at 14:54











          • There was a mistake in my config example. header_checks was set to a file path, but as it contains regex rules the path needs to be prefixed with pcre:

            – Murphy's Prophet
            Jun 9 '18 at 2:37













          1












          1








          1







          You should be able to do this without a custom transport, using built-in header checks.



          Add to main.cf:



          header_checks = pcre:/etc/postfix/rewrite_headers


          Your rewrite_headers file will have the existing rule wrapped in a conditional:



          if /^To: email@example.com$/i
          /^Subject: (.+)$/i REPLACE Subject: [Example tag] $1
          endif


          This should handle everything without the need for a transport config.






          share|improve this answer















          You should be able to do this without a custom transport, using built-in header checks.



          Add to main.cf:



          header_checks = pcre:/etc/postfix/rewrite_headers


          Your rewrite_headers file will have the existing rule wrapped in a conditional:



          if /^To: email@example.com$/i
          /^Subject: (.+)$/i REPLACE Subject: [Example tag] $1
          endif


          This should handle everything without the need for a transport config.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 9 '18 at 2:36

























          answered Jan 19 '18 at 22:14









          Murphy's ProphetMurphy's Prophet

          112




          112












          • Is this also going to work if I want to change the sender of the mail for specific recipients?

            – wie5Ooma
            Jan 19 '18 at 22:46











          • Thanks for the tips. Unfortunately for me, my postfix config doesn't work as per documentation. header_checks doc says the header is checked in one bunch, not line by line. But this doesn't work accordingly to my config. So your tip doesn't work on my config.

            – Luc-Olivier
            May 25 '18 at 14:54











          • There was a mistake in my config example. header_checks was set to a file path, but as it contains regex rules the path needs to be prefixed with pcre:

            – Murphy's Prophet
            Jun 9 '18 at 2:37

















          • Is this also going to work if I want to change the sender of the mail for specific recipients?

            – wie5Ooma
            Jan 19 '18 at 22:46











          • Thanks for the tips. Unfortunately for me, my postfix config doesn't work as per documentation. header_checks doc says the header is checked in one bunch, not line by line. But this doesn't work accordingly to my config. So your tip doesn't work on my config.

            – Luc-Olivier
            May 25 '18 at 14:54











          • There was a mistake in my config example. header_checks was set to a file path, but as it contains regex rules the path needs to be prefixed with pcre:

            – Murphy's Prophet
            Jun 9 '18 at 2:37
















          Is this also going to work if I want to change the sender of the mail for specific recipients?

          – wie5Ooma
          Jan 19 '18 at 22:46





          Is this also going to work if I want to change the sender of the mail for specific recipients?

          – wie5Ooma
          Jan 19 '18 at 22:46













          Thanks for the tips. Unfortunately for me, my postfix config doesn't work as per documentation. header_checks doc says the header is checked in one bunch, not line by line. But this doesn't work accordingly to my config. So your tip doesn't work on my config.

          – Luc-Olivier
          May 25 '18 at 14:54





          Thanks for the tips. Unfortunately for me, my postfix config doesn't work as per documentation. header_checks doc says the header is checked in one bunch, not line by line. But this doesn't work accordingly to my config. So your tip doesn't work on my config.

          – Luc-Olivier
          May 25 '18 at 14:54













          There was a mistake in my config example. header_checks was set to a file path, but as it contains regex rules the path needs to be prefixed with pcre:

          – Murphy's Prophet
          Jun 9 '18 at 2:37





          There was a mistake in my config example. header_checks was set to a file path, but as it contains regex rules the path needs to be prefixed with pcre:

          – Murphy's Prophet
          Jun 9 '18 at 2:37

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f252193%2fpostfix-rewriting-subject-for-specific-addresses%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown






          Popular posts from this blog

          Peggy Mitchell

          Palaiologos

          The Forum (Inglewood, California)