473,404 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

need help with inherited script that emails files

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.
{
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.

Jul 19 '05 #1
0 2426

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jeremy | last post by:
Hello, I am in search of a small simple script One that can allow us as Admins to upload files, then we would send emails to clents telling them where to login to download the files that we...
5
by: news | last post by:
I have a new situation I'm facing and could use a suggestion or two, as I don't seem to be able to think in the abstract very well. We have a local server which holds all of our image files. We...
0
by: 42 | last post by:
I implemented a simple class inherited from Page to create a page template. It simply wraps some trivial html around the inherited page, and puts the inherited page into a form. The problem I...
2
by: Mr. x | last post by:
Hello, I am sending emails with Hebrew contents. When receiving emails - I cannot see the Hebrew characters (it is not outlook express configuration, because when receiving emails from friends -...
2
by: Vanessa Lee | last post by:
Hello, Is it possible to write a script using CONDTS object to read all emails from the SMTP IIS "Drop" folder without changing the username and email address in LogonSMTP? or is there...
6
by: admin | last post by:
Hi, I have a mysql box that has a private network ip. The old developer was running our web server on this machine but the company since retired the box and it is in a closet, still running, but...
4
by: krishnakant Mane | last post by:
hello, I am a bit confused. I want to make a program that will take some data from a database and make a string of text. and send it to the respective email id of a person. next I also want to...
20
by: mike | last post by:
I help manage a large web site, one that has over 600 html pages... It's a reference site for ham radio folks and as an example, one page indexes over 1.8 gb of on-line PDF documents. The site...
10
by: sufian | last post by:
I am new to the world of PHP. Below is my simple PHP file "invite.php" with a form having an image send button (I have to use the image send button because it is the requirement, may be this is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.