1

I'm trying to play with the postfix after queue. Basically, I want to see if I can modify outgoing email. (I'm not interested at all in incoming email). I did the following (based on http://www.postfix.org/FILTER_README.html) :

  1. launch ec2 on aws (ubuntu 16.04)
  2. install postfix
  3. created filter with user filter
  4. modify the master.cf by adding the -o content_filter=filter:dummy

    smtp inet n - y - - smtpd -o content_filter=filter:dummy

  5. add the filter service definition at the end of the master.cf file

    filter unix - n n - 10 pipe flags=Rq user=filter null_sender= argv=/home/ubuntu/run_filter.sh -f ${sender} -- ${recipient}

  6. Send email using

    echo "hello world" | mail -s "second message" [email protected]

But the filter is not called. And the email is sent without any change.

It seems like I'm missing something very basic. If someone can help, thanks!

3
  • 1
    Did you check the log? Commented May 22, 2017 at 19:13
  • 2
    When you do that echo "hello world" | mail -s "second message" [email protected], what happens in /var/log/mail.log ? Commented May 22, 2017 at 19:18
  • Have you reloaded Postfix? Again: show the logs! Commented May 27, 2017 at 8:32

3 Answers 3

1

It could be that your php.ini isn't referencing the correct path to sendmail.

You can check your php.ini file or apache logs to confirm this.

Alternatively, you can use the absolute path instead:

echo "Subject: test" | /usr/sbin/sendmail [email protected] 

you can also confirm the registered path from command line:

which sendmail 

Good Luck :)

3
  • Maybe you could explain why trying that would make a difference. Commented May 24, 2017 at 18:57
  • 1
    Sorry, As you can see I'm quite new around here. I'll edit my answer now with further clarification. Commented May 25, 2017 at 15:24
  • Thanks Max. That's a much nicer answer. Good luck to you too. :) Commented May 25, 2017 at 23:42
0

I may be wrong as I don't know exactly your setup, but I think that mail does not send messages through smtp. You can check postfix logs, if your message is received via postfix/smtpd or via postfix/pickup.

You can configure mail to use smtp I think, depends what mail you have installed (mailx, nail etc).

0

This answer doesn't answer directly your question, but could help you more on long term.

When I have an application that I expect to do something, I am using tracing tools like strace, tcpdump/wireshark, perf, systemtap.

In your case, because I expect mail to connect via a TCP or at least an Unix socket to send the email, I would run it under strace.

echo "hello world" | strace -f -e network mail -s "second message" [email protected] 

-f = follow child processes too.

-e network = trace only network related system calls. You may use -e file to see which files are used. For more details see strace(1) man page

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.