Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > need help with inherited script that emails files

Reply
Thread Tools

need help with inherited script that emails files

 
 
:crp:
Guest
Posts: n/a
 
      01-25-2005
This perl script goes through a list of files in IFILE and for each file, it sends it on to sendmail. Attachments need special handling and are signified in the email-file by having a line start with 3@ folowed by the name of the file that should be attached.
Quote:
{
open IFILE,"$ifile";
$ofile="$_.mail";
open OFILE,">$ofile";
$fromaddr="PostMaster\@afts.com";
while(<IFILE>)
{
chomp;
if(substr($_,0,3) eq "\@\@\@")
{
chomp($basename=substr($_,3,(length $_)-4));
chomp($aname="/mnt/opserve/automail/ATTACH/" . $basename);
chomp($base="$aname.base64");
system "cat $aname | /usr/bin/mimencode -o $base";
print OFILE "\n--Message-Boundary--\n";
print OFILE "Content-type: Application/octet-stream; name=\"$basename\"\n";
print OFILE "Content-transfer-encoding: BASE64\n\n";
close OFILE;
system "cat $base >> $ofile";
open OFILE,">>$ofile";
system "cp $base /usr/mailAttached/`date +%d`/";
system "rm -f $base";
system "rm -f $aname";
print OFILE "\n--Message-Boundary--\n";
};
if(substr($_,0,5) eq "From:")
{
$fromaddr=(substr($_,5));
};
if(substr($_,0,3) ne "\@\@\@")
{
print OFILE $_ ."\n";
};
}
close IFILE;
There are 3 problems:
1) There has to be a way of doing this without all those system calls, no?
2) this Line does not always get processed:
"cp $base /usr/mailAttached/`date +%d`/"
3) sometimes the text string of
; type=Binary
gets added after the basename in the output of OFILE. The result is
Content-type: Application/octet-stream; name=Cycle108.zip; type=Binary
instead of
Content-type: Application/octet-stream; name=Cycle108.zip

this hurts as several email clients seem to have problems parsing the attached filename correctly.

Thanks.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
'Class.inherited' v. 'inherited' syntax inside Class 7stud -- Ruby 11 11-09-2007 06:45 PM
need help with a cart I inherited, need to increase number of total characters allowed fbspector@excaliburit.com Perl Misc 3 10-22-2007 02:34 PM
Need help with accessing control in inherited form =?Utf-8?B?Sm9l?= ASP .Net 3 02-08-2006 05:28 PM
Scanning my emails for harmfull emails etc lee.ingram Computer Support 4 01-12-2006 01:21 AM
How to stop Sir name showing on emails from hotmail emails Drifter Computer Information 3 07-07-2004 07:15 AM



Advertisments