Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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)
share|improve this question

1 Answer 1

up vote 2 down vote accepted

That's because you forgot -r in front of #{ARGV[0]} :)

share|improve this answer
    
I think this sums it up best: (╯°□°)╯︵ ┻━┻ (thanks!) –  mjbraun Nov 14 '12 at 16:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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