Hello friends,
Thanks for your suggestions. I am posting some part of the code here. (
The entire code is of more than 1500 lines ). I will mention the parts
which are added. The old code still runs fine.
The classes below are from both perl and C programs and are interfaced
by SWIG.
The modules used by the code:-
use CGI::Carp qw(fatalsToBrowser);
require 5.001;
use POSIX qw(strftime);
use perl_verify;
use getinfo;
use personal;
use preference;
use address;
use signature;
use misc;
use bcase; #### added ####
require "cgi-lib.pl";
The added part:-
#get_briefcase_home_dir(BRIEFCASE_ROOT_DIR, domain_name,
which_dot(domain_name));
$dot = &bcase::which_dot($mydomain);
$bcase_root_dir="";
$bcase_home_dir=&bcase::get_briefcase_home_dir($bcase_root_dir,$mydomain,$dot);
The files are opened and conditions are checked here:- (present even
earlier, but posting for o/p flushing):-
#if ($#mailtothese>=0 || $#mailccthese>=0 || $#mailbccthese>=0 ||
$toallusers) { #send an email, call 'sendmail'
if ($#mailtothese>=0 || $#mailccthese>=0 || $#mailbccthese>=0) { #send
an email, call 'sendmail'
$receipt = "";
if (defined($cgi_data{'rr'})) {
$receipt = "-N failure,delay,success";
}
if (!open(MAIL,"|$mailprog -oem -i -R hdrs -f$from -t $receipt >
/dev/null 2> /dev/null")) {
$sendmailerr = 1;
}
}
$read_receipt = "";
if (defined($cgi_data{'mdn'})) {
$read_receipt = "Disposition-Notification-To: $from\n";
}
if (defined($cgi_data{'sv'}) and $cgi_data{'sv'} eq 'yes') { #save a
copy? must send a different mail
open(MAILME,"|$mailprog -oem -i -R hdrs -f$from $from > /dev/null
2> /dev/null");
}
( other file descriptors are also initialized and operated upon in the
same war ).
select(STDOUT); $| = 1; #autoflush
if (FAXMAIL) { select(FAXMAIL); $| = 1; }
if (MAILALL) { select(MAILALL); $| = 1; }
if (MAIL) { select(MAIL); $| = 1; }
if (MAILME) { select(MAILME); $| = 1; }
Here's how the o/p is sent through sendmail:-
if (MAIL) {
print MAIL <<_TO_END_;
X-Originating-IP: $ENV{'REMOTE_ADDR'}
Reply-To: $fullname <$replytoemail>
From: $fullname <$from>
_TO_END_
}
Some added lines:-
#attach the number of files from Web Folders here
#@afarray;
#$nooffiles;
$nooffiles=0;
$wflist=$cgi_data{'filelist'};
if ($wflist ne ""){
@afarray=split(/,/,$wflist);
$nooffiles=scalar(@afarray);
$len = $ENV{'CONTENT_LENGTH'};
my $attach_file_size=0;
#&CgiError($cgi_lib'maxdata);
#my $fname=$bcase_home_dir . "/" . $f1;
#check for the file size here
for ($ii=0; $ii<$nooffiles; $ii++) {
# $tt=index(@afarray[$ii],"tmp:/");
$tt=index($afarray[$ii],"tmp:/");
if ($tt eq -1){
# $tempstr=$bcase_home_dir . "/" . @afarray[$ii];
$tempstr=$bcase_home_dir . "/" . $afarray[$ii];
}
else{
# $tempstr=@afarray[$ii];
$tempstr=$afarray[$ii];
$tempstr=~ s/://g;
if ($tempstr ne ""){
$tempstr="/". $tempstr;
}
}
$tempstr=~ s/ /\\ /g;
$scratch=0;
$scratch=&bcase::get_file_size($tempstr);
$attach_file_size= $attach_file_size+ $scratch;
}
$attach_file_size=$attach_file_size+$len;
#&CgiError("FIle size so far " . $attach_file_size);
if ($attach_file_size>$cgi_lib'maxdata) {
&CgiDie("Request to receive too much data(more than
$cgi_lib'maxdata bytes): $cgi_lib'maxdata-$attach_file_size bytes\n");
}
for ($ii=0; $ii<$nooffiles; $ii++) {
# $tempstr= @afarray[$ii];
$tempstr= $afarray[$ii];
attach_file_wf($tempstr);
#$tempstr=$tempstr . @afarray[$ii] . ",";
}
}
The o/p to html page begins from here. There is no change to it:-
&misc::functions_before($envlp, $cgi_data{'f'}, $cgi_data{'m'},
$cgi_data{'s'}, "Message Sent");
The function recently added:-
sub attach_file_wf {
my $f1 = $_[0];
my $ctype;
my $fname=$bcase_home_dir . "/" . $f1;
my $tt;
my @mypath = split(/\/|\\/, $f1);
my $upfile1name = pop(@mypath);
my $deletefile="";
#check for the zip file
$tt=index($f1,"tmp:/");
if ($tt ne -1){ $deletefile="delete"; $fname="/tmp/" .
$upfile1name}
#my $upfile1name =$f1;
if ($upfile1name) { }
else { $upfile1name = 'anonymous'; }
#if (open (TMPFILE, "< $cgi_sfn{$f1}")) {}
#$string =~ s/regex/replacement/g;
my $ff=$fname;
$ff=~ s/ /\\ /g;
#$upfile1name=~ s/ /\\ /g;
#&CgiError("fname " . $ff);
if (open (TMPFILE, "< $fname")) {
#if (!defined($cgi_ct{$f1}) or $cgi_ct{$f1} eq "") {
#$cgi_ct{$f1} = "application\/octet-stream";
$ctype = &bcase::findmimetype($ff);
#&CgiError(" ctype " . $ctype);
if ($ctype eq ""){
$ctype = "application\/octet-stream";
}
#}
$cte = "BASE64";
$decodeflag = "-b";
if ($ctype =~ /^text\//i) {
$cte = "quoted-printable"; $decodeflag = "-q";
}
seek(TMPFILE, 0 ,2);
if (tell(TMPFILE) > 0) {
close(TMPFILE);
if (FAXMAIL) {
$upfaxfile1name = $upfile1name;
if (($upfile1name =~ /^iefaxing.sig$/i) or ($upfile1name =~
/\.grp$/i)) {
$upfaxfile1name .= ".ren";
}
print FAXMAIL <<_TO_END_;
--$mkmailid
Content-Type: $ctype; name=$upfaxfile1name
Content-Transfer-Encoding: $cte
_TO_END_
}
if (MAILALL) {
print MAILALL <<_TO_END_;
--$mkmailid
Content-Type: $ctype; name=$upfile1name
Content-Transfer-Encoding: $cte
_TO_END_
}
if (MAIL) {
print MAIL <<_TO_END_;
--$mkmailid
Content-Type: $ctype; name=$upfile1name
Content-Transfer-Encoding: $cte
_TO_END_
}
if (MAILME) {
print MAILME <<_TO_END_;
--$mkmailid
Content-Type: $ctype; name=$upfile1name
Content-Transfer-Encoding: $cte
_TO_END_
}
if (FAXMAIL) { print FAXMAIL `$mimencoder $decodeflag $ff`
or print FAXMAIL "ERROR:
Can't open $mimencoder to encode the attachment : $!\n"; }
if (MAILALL) { print MAILALL `$mimencoder $decodeflag $ff`
or print MAILALL "ERROR:
Can't open $mimencoder to encode the attachment : $!\n"; }
if (MAIL) { print MAIL `$mimencoder $decodeflag $ff` or
print MAIL "ERROR: Can't open $mimencoder to encode the attachment :
$!\n"; }
if (MAILME) { print MAILME `$mimencoder $decodeflag $ff` or
print MAILME "ERROR: Can't open $mimencoder to encode the attachment :
$!\n"; }
#unlink ($cgi_sfn{$f1}) if (-e $cgi_sfn{$f1});
if ($deletefile eq "delete"){
unlink ($fname) if (-e $fname);
}
}
else {
close(TMPFILE);
#unlink ($cgi_sfn{$f1}) if (-e $cgi_sfn{$f1});
if ($deletefile eq "delete"){
unlink ($fname) if (-e $fname);
}
}
}
}
PLEASE HELPPPPPP.