logo       

smtpauth with unmodified qmail (Re: My solution to these licensing issues:): msg#00057

Subject: smtpauth with unmodified qmail (Re: My solution to these licensing issues:)
On Sat, 10 Jan 2004, Chris Travers wrote:

> Recommend Postfix for areas where auth-smtp and other advanced features are
> required.

Inbound smtp auth can be done with Bruce Guenter's smtpfront-qmail. 

Outbound SMTP auth can be done via an smtp proxy listing on a loopback 
port, and a custom smtproute (either global, or per domain). So there's no 
absolute need to patch qmail for either of those.

Sample code follows, for those interested. Little tested. If anyone finds
a bug, please let me know.

#!/usr/bin/perl -w -T

package SMTPAuthProxy;

use strict;
use vars qw(@ISA);
use Net::Server::Fork;
use Net::SMTP;

@ISA = qw(Net::Server::Fork);

SMTPAuthProxy->run(
                max_servers => 4,
                proto => 'tcp',
                user => 'nobody',
                group => 'nobody',
                host => 'localhost',
                port => 26);
exit;

### over-ridden subs below

sub process_request
{
    my $self = shift;
    my $smtp = $self->{smtp};
    my $kidpid;

    die "can't fork: $!" unless defined ($kidpid = fork());
    if ($kidpid)
    {
        my $line;
        while (defined ($line = <STDIN>))
        {
            print $smtp $line;
        }
        kill ("TERM" => $kidpid);
    }
    else
    {
        my $line;
        while (defined ($line = <$smtp>))
        {
            print STDOUT $line;
        }
    }
}

sub post_accept_hook
{
    my $self = shift;
    my $smarthost = "mail.domain.com";  # say
    my $me = "me";
    my $name = "name"; # FIXME
    my $pass = "pass"; # FIXME

    my $smtp = Net::SMTP->new($smarthost,
                            Hello => $me,
                            #Debug => 1,
                        );
    if ($smtp->supports("AUTH"))
    {
        unless ($smtp->auth($name, $pass))
        {
            print "451 Could not auth to mail server\n";
            warn "SMTP authentication with ISP server failed\n";
            $smtp->quit;
            exit;
        }
    }
    else
    {
        warn "Upstream SMTP server does not support authentication\n";
    }
    $self->{smtp} = $smtp;
    print "220 ", $smtp->banner;
}

1;

--
Charlie




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
linux.arklinux....    user-groups.lin...    kde.usability/2...    ietf.ipp/2002-0...    mail.spam.spamc...    os.netbsd.devel...    audio.cd-record...    text.unicode.de...    php.documentati...    games.fps.halfl...    window-managers...    suse.oracle.gen...    bug-tracking.gn...    video.dvdrip.us...    xfree86.cvs/200...    java.netbeans.m...    network.argus/2...    culture.sf.kill...    debian.ports.al...    freebsd.questio...    qplus.devel/200...    handhelds.palm....   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe