1

This is what I am trying to do:

I have a server using Postfix on a Ubuntu precise 64bits and I have a table list of emails in /etc/postfix/virtual, like this:

artz@mydomain.com  artz@gmail.com
artz2@mydomain.com artz@yahoo.com

Now I want to put a filter that get all mails sent and add some prefix to the subject or add something else to the end of the mail.

In the file /etc/postfix/master.cf I put:

filter    unix  -       n       n       -       10      pipe
  flags=Rq user=filter argv=/home/filter/filtro.php -f ${sender} -- ${recipient}

I created the user filter and put the file /home/filter/filtro.php:

#!/usr/bin/php
<?php
$myFile = "/home/filter/testFile.txt";
$fh = fopen($myFile, 'a');
fwrite($fh, "\n-----------------------\n");
fwrite($fh, json_encode($_SERVER['argv']) );
?>

It was just to see if it´s working. But it´s not. Anyone can see a light for my problem?

Thanks!

  • What are you trying to achieve? It will be better if u can say what u want exactly. – clement Mar 6 '14 at 17:57
  • Ok. Right. I didnt do anything inside filtro.php because I wanted to see if this filter would work, but what I want to do is add something like [artz@mydomain.com] before the subject text and add a text at the end of the content message saying "This message was sent to artz@mydomain.com." – Arthur Felipe Mar 6 '14 at 18:30
0

You can use mimedefang configured as smtpd_milter with postfix. It can change/add/delete headers (action_change_header/action_insert_header/action_delete_header) and append text (append_text_boilerplate) to the mails. More info here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.