
patk
Deleted
Aug 3, 2000, 10:41 AM
Post #1 of 3
(172 views)
|
I'm trying to make a script run that will allow someone to attach a file (any file) to an email. I have MIME Lite installed and I can do this: #!/bin/perl $|++; use MIME::Lite; $msg = new MIME::Lite From =>'patk@self-made-man.com', To =>'patk@perlguru.com', Cc =>'self-made-man@self-made-man.com, some1@self-made-man.com', Subject =>'Sub', Type =>'multipart/mixed'; attach $msg Type =>'TEXT', Data =>"Here's the GIF file you wanted"; attach $msg Type =>'image/gif', Path =>'2.gif', Filename =>'2.gif'; $mailprog ="/usr/lib/sendmail"; open(MAIL, "| $mailprog -t "); $msg->print(\*MAIL); close(MAIL); that works, and so does this upload script: $allowall = "yes"; $theext = ".gif"; $donepage = $ENV{'HTTP_REFERER'}; use CGI; $onnum = 1; while ($onnum != 11) { my $req = new CGI; my $file = $req->param("FILE$onnum"); if ($file ne "") { my $fileName = $file; $fileName =~ s!^.*(\\|\/)!!; $newmain = $fileName; if ($allowall ne "yes") { if (lc(substr($newmain,length($newmain) - 4,4)) ne $theext){ $filenotgood = "yes"; } } if ($filenotgood ne "yes") { open (OUTFILE, ">$basedir/$fileName"); print "$basedir/$fileName<br>"; while (my $bytesread = read($file, my $buffer, 1024)) { print OUTFILE $buffer; } close (OUTFILE); } } $onnum++; } that works too. But I have no idea how to intergrate them together? If possible, I would like a user to input the subject line, to, cc, from, etc. When I try $c = $in{'c'}; Cc=>'$c', it will appear as $c and not the data of $c. So what I'm thinking is something like: #!/bin/perl require "cgi-lib.pl"; &ReadParse; $to = $in{'to'}; $from = $in{'from'}; $subject = $in{'subject'}; &Upload; &Atach_Send; sub Upload { # Upload files to /tmp } sub Attach_Send { # Attach file to email, send email to $to } exit; Thanks for any help! Pat
|