Hi All,
I'm trying to understand how content_filter works. According to the
documentation I can create a simple script and use content_filter to send
an e-mail to it.
That's my config of master.cf:
proxy unix - n n - 10 pipe
flags=Rq user=filter null_sender=
argv=/usr/local/bin/proxy -f ${sender} ${recipient}
smtp inet n - n - - smtpd
-o content_filter=proxy:dummy
So that's exactly the same as an example from to doc.
And now, my script is:
IO.popen("/usr/sbin/sendmail -G -i #{my_str}", "w") do |pipe|
pipe.puts @mail_content
pipe.close_write
end
Where my_str is a string of all arguments (sender and recipients):
ARGV.each { |recipient| my_str.concat("#{recipient} ") }
which is basically:
"-f sender@mymail user1@mymail user2@mymail"
The point os using it that way is because I noticed that bcc e-mail is on
that list and in the same way it's not in the mail headers. So I'm sending
that list of all recipients to the sendmail so I can put an e-mail again to
the queue without changing anything (and not losing bcc).
It works fine but when I change it to the Golang and I did mostly the same:
func sendMail(recipients string, maildata []byte) int {
cmd := exec.Command("/usr/sbin/sendmail", "-G", "-i", recipients)
pipe, err := cmd.StdinPipe()
if err != nil {
log.Fatal(err)
}
if err = cmd.Start(); err != nil {
log.Fatal(err)
}
fmt.Fprintf(pipe, "%s", maildata)
err = pipe.Close()
if err != nil {
log.Fatal(err)
}
return 0
}
So exactly like in Ruby I'm executing sendmail:
/usr/sbin/sendmail -G -i (recipients from postfix ARGS)
but that does not work, on the logs I have:
warning: -f option specified malformed sender: ...
and
fatal: Recipient addresses must be specified on the command line or via
the -t option
I'm not really sure why is that. Why it works in Ruby and not in Go? I'm
calling it in exactly the same way and I have the same output on the
console. How I should handle it?
Can someone give me some hint?
Thanks,
Pawel