BODYSTRUCTURE question

Robert Mueller robm at fastmail.fm
Tue Feb 27 18:45:41 EST 2007


> Nice!  Is this code available for public consumption?  I'd love to use
> something like this to strip out \0s in messages too.  Most of the other
> "solutions" for cyrus/postfix that I've seen required an additional
> exec() in the delivery pipeline, which I would like to avoid.

It's all done in perl, and the actual complete proxy is in house
unfortunately, however some of the surrounding modules are available.

http://cpan.robm.fastmail.fm/other/

Unfortunately the documentation is a bit old or lacking, but the basic
idea is something like:

package LmtpProxy;
use base qw(Net::Server::Fork Net::XmtpServer);

LmtpProxy->run(
  port => "/var/imap/socket/lmtpproxy",
  xmtp_personality => 'lmtp',
  handle_mime => 1,
);

sub new_connection {
  $_[0]->send_client_resp(220, "Welcome");
}
sub helo {
  $_[0]->send_client_resp(250, "Helo ok");
}
sub mail_from {
  $_[0]->{mail_from} = $_[1];
  $_[0]->send_client_resp(250, "RCPT TO ok");
}

... etc rcpt_to, begin_data, end_data, rset ...
... you can also hook into begin_body, end_body, begin_headers,
end_headers, header, etc

sub header {
  if (lc $_[1] eq "content-type") {
    $_[2] =~ s{^([\w\-]+/[\w\-]+)(\s+[\w\-]+\s*=)}{$1;$2};
  }
}

sub end_data {
  # open Net::XmtpClient connection to backend server to replay lmtp
  commands
}

Rob

----------
robm at fastmail.fm
Sign up at http://fastmail.fm for fast, ad free, IMAP accessible email



More information about the Info-cyrus mailing list