[Pymilter] Change Body from header in a mail (newbie question)

Abhijeet Rastogi abhijeet.1989 at gmail.com
Thu May 9 07:49:38 EDT 2013


Hi all,

As we know, there are two "from" in a mail. The actual envelope
mailfrom and the body from. I'm trying to change body "from" whenver
"envelope mailfrom" and "body from" don't match.

For that, I picked the official example.
http://pythonhosted.org/pymilter/milter-template_8py-example.html and
edited the below code.

  def header(self, name, hval):
    if name == "From":
        if self.F != hval:
            self.log("<" + hval.strip("<>") + "via " + self.F.strip("<>") + ">")
            hval = hval + "via" + self.F

    self.fp.write("%s: %s\n" % (name,hval))     # add header to buffer
    return Milter.CONTINUE

I can see by adding "self.log" statements that the header is actually
being changed but when I receive the mail, I still see the original
body from. Why can that be so? I even tried the
"Milter.set_flags(Milter.CURR_ACTS)", still it's not changing the body
from.

It's my first milter writing experience and I'm stuck at this. Any
help would be highly appreciated.

--
Regards,
Abhijeet Rastogi (shadyabhi)
http://blog.abhijeetr.com



More information about the Pymilter mailing list