How to stop basic Postfix after-queue script from BCC-ing sender?
- by mjbraun
I'm building a content filter for Postfix (2.9.3 package installed via apt on an Ubuntu 12.04 test VM) and I'm starting with a very basic Ruby (1.9.3) template and building up functionality. Strangely, when the script is enabled, messages sent are being forwarded on as normal, but also sent back to the sender which is not normal. Disabling the script disables this behavior. Any suggestions about what I have to change to stop that from happening? Thanks for any advice!
/etc/postfix/master.cf (only the lines changed from the default)
smtp inet n - - - - smtpd -o content_filter=dumper:dummy
...
dumper unix - n n - 10 pipe
flags=RF user=mailuser argv=/home/mailuser/mailfilter/dumper.rb ${sender} ${recipient}`
/home/mailuser/mailfilter/dumper.rb
#!/usr/bin/env ruby
require 'open3'
dir="/home/mailuser/emails"
logfile="maillog.log"
message = $stdin.read
cmd = "/usr/sbin/sendmail -G -i #{ARGV[0]} #{ARGV[1]}"
stdin, stdouterr, wait_thr = Open3.popen2e(cmd)
stdin.print(message)
logfile = File.open("#{dir}/#{logfile}", 'a')
logfile.write(stdouterr)
stdin.close
stdouterr.close
exit(0)