#! /usr/bin/perl # # $Id$ # Copyright (C) 2002-2003 Jan Kratochvil # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA package PerlMail::Config; use vars qw($VERSION); $VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; }; use strict; use warnings; require Exporter; use vars qw(@ISA @EXPORT); @ISA=qw(Exporter); @EXPORT=qw( $HOME $Mail @ValidUsers $IdleMax $MaxBodySMS @SMSwebRcpt $SMSwebRcpt_username $Lock_pathname $PeerAddr $Socket_timeout $DB_table $DBI_database $DBI_user $DBI_pwd $sendmail_orig @addr_addon &FromAddress @h_rcpt @h_from); require Mail::Alias; # perlmail-accept & perlmail-sendmail our $HOME="/home/lace"; # perlmail-accept our $Mail="$HOME/Mail"; our @ValidUsers=qw(root lace short kratochvil _local); our $IdleMax=10; our $MaxBodySMS=0x1000; # max bytes to pass to Lingua::EN::Squeeze our @SMSwebRcpt=qw(420 602 431329); our $SMSwebRcpt_username="lace2"; # perlmail-submit our $Lock_pathname="/tmp/PerlMail.lock"; our $PeerAddr="exuhome.dyn.jankratochvil.net.:852"; #our $PeerAddr="127.0.0.1:2852"; our $Socket_timeout=7600; # 15sec is NOT enough! our $DB_table="PerlMail_folder"; our $DBI_database="short"; our $DBI_user="short"; our $DBI_pwd=$ENV{"HOME"}."/priv/mysql.".$DBI_user.".pwd"; # perlmail-sendmail our $sendmail_orig=(-x ($_="/usr/sbin/sendmail-orig") ? $_ : "/usr/sbin/sendmail"); # Mail-Alias-1.12 defaults to "/etc/mail/aliases" which does not exist on RedHat sendmail-8.12.5-7 # Mail-Alias-1.12 will clutter $_ ! our @addr_addon=(Mail::Alias->new("/etc/aliases")->exists("sentout") ? ("sentout") : ()); our $opt_F; # imported our $is_pgp; # imported sub FromAddress { my($rcpt,$iserror)=@_; my $phrase=(defined $opt_F ? $opt_F : "Jan Kratochvil"); { last if !$is_pgp; last if $iserror; local *F; local $_; my $filename="$HOME/.gnupg/options"; open F,$filename or do { warn "Open \"$filename\": $!"; last; }; local $/="\n"; my @keys=map((/^\s*default-key\s+(\S+)\s*$/),); @keys==1 or do { warn "Found ".scalar(@keys)." 'default-key's in your \"$filename\", ignoring"; last; }; close F or warn "Close \"$filename\": $!"; my $default_key=$keys[0]; $default_key=~/^[[:xdigit:]]{8}$/ or do { warn "Invalid 'default-key', ignoring: $default_key"; last; }; return Mail::Address->new( $phrase, 'pgp-'.uc($default_key).'@jankratochvil.net', ); } # !$is_pgp or fallback return Mail::Address->new( $phrase, (!$iserror ? 'rcpt' : 'rcpterr') .'-' .(defined($rcpt->user()) ? $rcpt->user() : "NOUSER") .".AT." .(defined($rcpt->host()) ? $rcpt->host() : "LOCAL") .'@jankratochvil.net', ); } # RedHat sendmail-8.9.3-20/src/conf.c/HdrInfo[]/\Q/* destination fields */\E # FIXME: Recognize "Resent-$_" headers for -t but when we are in 'resent' mode? our @h_rcpt=( # case in-sensitive! "To", "Cc", "Bcc", "Apparently-To", ); # ordering matters; first header found is substituted # last header is subsituted if no one is found our @h_from=( "Resent-From", "From", );