Postfix Pipe command

Discussion in 'Server Operation' started by Marc A Henning, Dec 17, 2019.

Tags:
  1. Marc A Henning

    Marc A Henning New Member

    I am trying to run a script when postfix receives an email and have found an example that I mostly understand.

    my_shell_script unix - n n - - pipe flags=F user=MY_USERNAME argv=/path/to/my/shell/script ${sender} ${size} ${recipient}

    However this example has some macros at the end ${sender}${size} ${recipient} at end that I don't really understand. The postfix manual says

    "In the command argument vector, the following macros are recognized and replaced with corresponding information from the Postfix queue manager delivery request."

    So for example ${sender}

    "This macro expands to the envelope sender address. By default, the null sender address expands to MAILER-DAE-MON; this can be changed with the null_sender attribute, as described above. This information is modified by the q flag for quoting."

    Could someone in layman terms explain what this means? And why it is put at the end of the configuration?


    Follow up Postfix question. When I run the command after I receive an email the file permissions for created files do not appear to match my umask. For example I have the bash command:

    echo "test" >> /var/log/CamLogs/ouput.txt

    if this output.txt file is not there it is created with -rw-------. Why would this be? My umask is set to 0002 so if I run the same command outside of pipe the created file would have -rw-rw-r--.
     
    Last edited: Dec 17, 2019
  2. Steini86

    Steini86 Active Member

    It defines how the special case is treaded, if there is no envelope sender address given. Then the variable will be set to "MAILER-DAEMON". This can be changed, but I think you won't need that ;)
    What do you mean by "put at the end"?

    Is this the umask for the postfix user or "you"? Apart from that I can't help, have never done something like that by myself, sry.
     
  3. Marc A Henning

    Marc A Henning New Member

    I mostly just meant is it necessary? What would happen if I didnt include these 3 macros? Why just these specific 3?
     
  4. Steini86

    Steini86 Active Member

    Well, when an email comes, "/path/to/my/shell/script" is executed and as parameters gets the values of the macros. That is in this example the sender mail address, the size of the mail and the recipient address. I do not know what the script then does with these values.
    If you do not include these macros, then the shell script will not have them (?)
    I think I do not get the question right, sorry.
     
  5. Marc A Henning

    Marc A Henning New Member

    O I think I get it. I could use the ${sender} variable in the script and it would already be defined. Ill have to test that when I get home.
     
    Last edited: Dec 17, 2019

Share This Page