I found this script that allows for mailing attatchments, pariticularly ZIP files to people, but I need some help with manipulating it.. This is the file itself:
#!/usr/bin/perl ### User variables - you may change things in this section as indicate +d ### # Change this to the correct path to Sendmail for your system # $mailprog="/usr/sbin/sendmail"; # Change this to the LITERAL PATH to the files you wish to mail. Do no +t forget the ending / # $filelocation="/path/to/your/cgi-bin/attachit/";
# Change this to the email address you want mails to be sent FROM and +leave \ behind the @ sign# $adminmail="You\@YourDomain.com"; # Change this to the name you want mails to be sent FROM # $adminname="Webmaster"; # Change this to reflect the subject line you require for your mails # $subjectline="Your Download"; # Change this to show the message you want to include (i.e. the body o +f the email). # # A new line is entered by using \n e.g. Hi there\n\nThank-you for you +r interest in blah blah # # Note that "Dear Name\n\n" has been inserted for you automatically, N +ame being the name submitted # $message="Thank-you for your interest, we have pleasure in attaching s +omething small and hopefully relevant.\n\nRegards,\nEtc."; # Change this to the URL of the screen you want to display after the u +ser has submitted the form # #(i.e. a confirmation screen)# $returnscreen="http://www.YourDomain.com/confirm.htm"; # DO NOT alter anything from here on # read (STDIN,$temp,$ENV{'CONTENT_LENGTH'}); @pairs=split(/&/,$temp); foreach $item(@pairs) { ($key,$content)=split (/=/,$item); $content=~tr /+/ /; $content=~s /%(..)/pack("c",hex($1))/ge; $fields{$key}=$content; } require ("mimetypes.pl"); &sendproduct; sub sendproduct { $file=$filelocation.$fields{'attachment'}; ($ext) = $file =~ m,\.([^\.]*)$,; $ext =~ tr,a-z,A-Z,; $fext=&mimetype($ext); my @boundaryv = (0..9, 'A'..'F'); srand(time ^ $$); for (my $i = 0; $i++ < 24;) { $boundary .= $boundaryv[rand(@boundaryv)]; } open MAIL, "| $mailprog -t"; print MAIL "To: $fields{'email'}($fields{'name'})\n"; print MAIL "From: $adminmail ($adminname)\n"; print MAIL "MIME-Version: 1.0\n"; print MAIL "Subject: $subjectline\n"; print MAIL "Content-Type: multipart/mixed; boundary=\"------------$bou +ndary\"\n"; print MAIL "\n"; print MAIL "This is a multi-part message in MIME format.\n"; print MAIL "--------------$boundary\n"; print MAIL "Content-Type: text/plain; charset=us-ascii\n"; print MAIL "Content-Transfer-Encoding: 7bit\n\n"; print MAIL "Dear $fields{'name'},\n\n"; print MAIL $message; print MAIL "\n"; print MAIL "--------------$boundary\n"; print MAIL "Content-Type: $fext; name=\"$fields{'attachment'}\"\n"; print MAIL "Content-Transfer-Encoding: base64\n"; print MAIL "Content-Disposition: attachment; filename=\"$fields{'attac +hment'}\"\n\n"; my $buf; $/=0; open INPUT, "$file"; binmode INPUT if ($^O eq 'NT' or $^O eq 'MSWin32'); while(read(INPUT, $buf, 60*57)) { print MAIL &encode_base64($buf); } close INPUT; print MAIL "\n--------------$boundary--\n"; print MAIL "\n"; close MAIL; print "Location: $returnscreen\n\n"; exit(); } sub encode_base64 #($) { my ($res, $eol, $padding) = ("", "\n", undef); while (($_[0] =~ /(.{1,45})/gs)) { $res .= substr(pack('u', $1), 1); chop $res; } $res =~ tr#` -_#AA-Za-z0-9+/#; # ` help emacs $padding = (3 - length($_[0]) % 3) % 3; # fix padding at the + end $res =~ s#.{$padding}$#'=' x $padding#e if $padding; # pad eoedv da +ta with ='s $res =~ s#(.{1,76})#$1$eol#g if (length $eol); # lines of at +least 76 characters return $res; }
And the MIME Type include looks like this:
sub mimetype { my %mime = ( #-------------------------------------<TEXT>----- 'HTML', "text/html", 'HTM', "text/html", ..... 'WRL', "x-world/x-vrml", 'VRML', "x-world/x-vrml", 'VRJ', "x-world/x-vrt", 'VRJT', "x-world/x-vrt", ); local ($y) = @_; $fext = $mime{$y}; return ($y); } return 1;

"I am loved by few, hated by many, and wanted by plenty." -Kage (Alex)
SkarySkriptz

In reply to MIME Type Mailer Question by Kage

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.