3 # kartero -- a user-session Mail Relay Agent
5 # Copyright (C) 2007 Zak B. Elep <zakame@spunge.org>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with this program; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 use Net
::SMTP
::Server
;
28 use Net
::SMTP
::Server
::Client
;
29 use Net
::SMTP
::Server
::SmartHost
;
31 our $VERSION = $Net::SMTP
::Server
::SmartHost
::VERSION
;
34 tie
%ini, 'Config::IniFiles', -file
=> "$ENV{HOME}/.karterorc";
36 my $server = Net
::SMTP
::Server
->new($ini{server
}{host
}, $ini{server
}{port
})
37 or croak
"Unable to start SMTP server at "
38 . "$ini{server}{host}:$ini{server}{port}: $!\n";
40 my $smarthost = (split ':' => $ini{relay
}{smarthost
})[0] || 'localhost';
41 my $port = (split ':' => $ini{relay
}{smarthost
})[1] || 25;
43 my $relay = Net
::SMTP
::Server
::SmartHost
->new($smarthost, $port);
45 while (my $conn = $server->accept) {
46 my $client = Net
::SMTP
::Server
::Client
->new($conn)
47 or croak
"Unable to handle client connection: $!\n";
49 $client->process || next;
51 $relay->auth($ini{relay
}{username
}, $ini{relay
}{passwd
})
52 if defined($ini{relay
}{username
}) && defined($ini{relay
}{passwd
});
55 my $time = time2str
("%a, %e %h %Y %X %z", time);
57 ($received = <<" EOF") =~ s/^\s\s//gm;
58 Received
: from
$ENV{USER
} by
$ini{server
}{host
}
59 with
local (kartero
$VERSION); $time
62 $relay->relay($client->{FROM
}, $client->{TO
}, $received . $client->{MSG
});
70 kartero - relay mails to a smarhost
80 C<kartero> is a program that relays outgoing mail from a Mail User Agent
81 (MUAs such as KMail, Gnus, or Icedove) to a ``smart host'' that does the
82 actual transport to the mail's destination. It uses the bundled
83 Net::SMTP::Server::SmartHost module to spawn a local SMTP server that
84 the user's MUA can talk to, and relay, outgoing mail.
89 C<kartero> is configured by reading the C<.karterorc> file in the user's
90 home directory. This configuration file follow the INI convention
91 commonly found in many Windows applications.
100 Name of the host where C<kartero> will listen on.
104 Name of the port where C<kartero> will listen on.
115 Name of the account for this smarthost.
119 The actual address of the smarthost.
123 Whether C<kartero> should authenticate to the smarthost.
127 When C<auth = yes>, use this username for authentication.
131 When C<auth = yes>, use this password for authentication.
138 L<Net::SMTP>, L<Net::SMTP::Server>, L<Net::SMTP::Server::Client>,
139 L<Net::SMTP::Server::SmartHost>.
141 L<kartero> is part of the L<kartero> suite.
146 Zak B. Elep, E<lt>zakame@spunge.orgE<gt>
149 =head1 COPYRIGHT AND LICENSE
151 Copyright (C) 2007 by Zak B. Elep
153 This program is free software; you can redistribute it and/or modify
154 it under the terms of the GNU General Public License as published by
155 the Free Software Foundation; either version 2 of the License, or
156 (at your option) any later version.
158 This program is distributed in the hope that it will be useful,
159 but WITHOUT ANY WARRANTY; without even the implied warranty of
160 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
161 GNU General Public License for more details.
163 You should have received a copy of the GNU General Public License along
164 with this program; if not, write to the Free Software Foundation, Inc.,
165 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.