——#!/usr/bin/perl -T
# $File: //depot/libOurNet/BBS/script/bbsmail $ $Author: autrijus $
# $Revision: #1 $ $Change: 3790 $ $DateTime: 2003/01/24 19:08:46 $
$VERSION
=
'0.04'
;
$REVISION
=
"rev$1\[\@$2\]"
if
(
'$Revision: #1 $ $Change: 3790 $'
=~ /(\d+)[^\d]+(\d+)/);
use
strict;
=head1 NAME
bbsmail - Internet to BBS email-gateway handler
=head1 SYNOPSIS
In F</usr/local/etc/bbs.rc> or F</etc/bbs.rc>;
# $DUMP = '/tmp/msgdump.tmp'; # Dump message to disk; halt
$MAIL_LOG = '/var/log/bbsmail.log'; # Log of bbsmail
$BOARD_LOG = '/var/log/bsboard.log'; # Log of bbsboard
$SIZE_LIMIT = 204800; # size limit of attachments
# Set virutal hosts; The C<bbs.> prefix of keys should be omitted.
%DOMAINS = (
'elixus.org' => {
BASEURL => 'http://elixus.org',
WWWHOME => '/srv/www/elixir',
PARAM => ['MELIX', '/home/melix'],
OWNER => 'melix',
GROUP => 'melix',
},
'cvic.org' => {
BASEURL => 'http://cvic.org',
WWWHOME => '/srv/www/cvic',
PARAM => ['CVIC', '/srv/bbs/cvic',
1003, 2500, 1005, 250, 1004, 50000], # needs utmp
OWNER => 'cvic',
GROUP => 'bbs',
},
'm543.com' => {
BASEURL => 'http://m543.com',
WWWHOME => '/srv/www/m543',
PARAM => ['CVIC', '/srv/bbs/m543',
1103, 2500, 1105, 250, 1104, 50000], # needs utmp
OWNER => 'cvic',
GROUP => 'bbs',
},
);
# multiple domains, same IP
$DOMAINS{'m543.org'} = $DOMAINS{'music543.org'} =
$DOMAINS{'music543.com'} = $DOMAINS{'m543.com'};
# fallback using the 'true' hostname
$DOMAINS{'geb.elixus.org'} = $DOMAINS{'elixus.org'};
# default domain for in-site mails
$DEFAULT_DOMAIN = 'elixus.org'
To configure it with sendmail, modify F<sendmail.cf> like this:
######################################
### Ruleset 0 -- Parse Address ###
######################################
R$+.bbs < @ $=w .> $#bbsmail $: $1 bbs mail gateway
R$+.board < @ $=w .> $#bbsboard $: $1 bbs board gateway
# handle locally delivered names
R$+.bbs $#bbsmail $:$1 bbs mail gateway
R$+.board $#bbsboard $:$1 bbs board gateway
##################################################
### Local and Program Mailer specification ###
##################################################
Mbbsmail, P=/usr/local/bin/bbsmail, F=lsSDFMuhP, S=10, R=20,
A=bbsmail $u
Mbbsboard, P=/usr/local/bin/bbsboard, F=lsSDFMuhP, S=10, R=20,
A=bbsboard $u
To feed it a MIME mail directly at the command line:
% bbsmail < message.txt
=head1 DESCRIPTION
This script relays e-mails sent to C<*.bbs@domain> as mails to
BBS user mailboxes; it is designed to be a drop-in replacement for
the MAPLE BBS utility of the same name.
This program could be used serve multiple BBS sites, each distinguished
by its domain name. MIME encodings, multipart messages, quoted words
are all handled correctly.
If supplied with a web directory, attachments could be saved for
later download. You could restrict the max. allowed size of each
attachments.
If the optional C<HTML::Parse> and C<HTML::FromText> modules were
installed, HTML-only mails and simple HTML attachments could be
rendered as plain text.
=head1 CAVEATS
Currently this script does not check proper permissions; you could
use the C<OurNet> backend to achieve restricted permission. See
L<bbscomd> for how to run an OurNet node.
However, authentication is currently not implemented; while sending
password via e-mail is easy, the author finds it distasteful. A
proper way to parse PGP-signed mail might be the only viable route,
and any contributions on that front will be most welcomed.
=cut
our
(
$Postfix
,
$Element
,
$Container
) =
qw/.bbs users mailbox/
;
my
$exec
=
'bbsboard'
;
my
$path
= $1
if
$0 =~ m|^(.+)/|;
do
"$path/$exec"
or
die
"can't execute $path/$exec: $@"
;
1;
__END__
=head1 SEE ALSO
L<OurNet::BBS>, L<bbsboard>.
=head1 AUTHORS
Autrijus Tang E<lt>autrijus@autrijus.orgE<gt>
=head1 COPYRIGHT
Copyright 2001-2002 by Autrijus Tang E<lt>autrijus@autrijus.orgE<gt>.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
=cut