PHP sendmail proxy (using xinetd)



I'm trying to write a sendmail proxy in PHP: people would connect to
my proxy running on port 25 (via xinetd), and the proxy would connect
to sendmail (tweaked to run on port 26).

Currently, the proxy is 100% transparent, but I plan to tweak it to
intercept sendmail's replies and substitute its own. My ultimate goal
is to implement sender-recipient-based greylisting (not IP-based
greylisting, which can be done without a proxy).

My problem: the proxy works fine when I test it, but seems to cutoff
some clients. I send the clients a "message accepted for delivery"
message and close the connection, but the client thinks it's been
cutoff and tries to deliver the mail again a little later (ironically,
this is the behavior I'll want when I start greylisting, but not
now!). This happens w/ legitimate ISP SMTP clients, not just spammers.

I suspect I'm doing something wrong with buffering or flushing. I made
both STDIN and the socket connection (to port 26, where sendmail's
running for real) nonblocking, since it's hardish to tell which one's
going to "speak" next.

Is there any generic proxy code I could use? An existing PHP sendmail
proxy would be even better.

Note: I realize that using a proxy means that *all* sendmail
connections appear to come from localhost, which is dangerous. Once in
production, my proxy will handle this situation by using xinetd's
REMOTE_HOST environment variable.

--
We're just a Bunch Of Regular Guys, a collective group that's trying
to understand and assimilate technology. We feel that resistance to
new ideas and technology is unwise and ultimately futile.
.



Relevant Pages

  • Re: [fw-wiz] FWTK and smap/smapd
    ... For example, for a good mail proxy consider postfix, ... In order to get more redundant setup I've made the outbound sendmail as ... sendmails have primary and secondary routes set accordingly back to them.. ...
    (Firewall-Wizards)
  • Re: transparent SOCKS proxy
    ... >> UDP packets on port 4201. ... How would the router know to tell the socks ... > clients inside the firewall can connect, ... > without the clients knowing anything of the proxy. ...
    (comp.os.linux.networking)
  • Re: FTP access via ISA(proxy)
    ... The funny thing is I personally have Proxy 2.0 and can FTP via that.. ... My understanding was that IE was port mode unless you set the PASV setting ... this is a good lead into why your Domain Host clients ...
    (microsoft.public.isa)
  • Re: FTP access via ISA(proxy)
    ... The funny thing is I personally have Proxy 2.0 and can FTP via that.. ... My understanding was that IE was port mode unless you set the PASV setting ... this is a good lead into why your Domain Host clients ...
    (microsoft.public.backoffice.smallbiz)
  • Re: hosts.deny behind proxy?
    ... > the internet behind a proxy. ... I'd like to block sites that are sending ... sendmail: 192.168.1.10 ...
    (comp.os.linux.networking)