Check out merlyn's article on the subject; I found it very useful when working on a similar project.

While working on the project, I made some observations you may find helpful (note that the following code has been simplified from the final, so certain typos may have been made):

if ( $copiesto ) { $msg->add( CC => $copiesto ); }
$msg->attach ( Disposition => 'attachment', Type => $sentinfo->{ 'Content-Type' }, Encoding => 'base64', Filename => $sentname, FH => $sentfile );
if ( defined( $settings{ "DEBUG" } ) ) { $msg->attach ( Type => 'TEXT', Encoding => 'base64', Filename => 'debug.txt', Disposition => 'attachment', Data => [ "Upload info\n\n", "File size = $sentsize\n", ( map { "$_ = $sentinfo->{ $_ }\n" } sort keys %$se +ntinfo ), "\n", "ENV Contents:\n\n", ( map { "$_ = $ENV{ $_ }\n" } sort keys %ENV ), "\n", "Configuration Settings:\n\n", ( map { "$_ = $settings{ $_ }\n" } sort keys %setti +ngs ) ] ); }
my $cgi = new CGI; my $sentfile = $cgi->upload( 'sentfile' ); my $sentsize; my $sentinfo; my $sentname; if ( $sentfile ) { $sentsize = -s ( $sentfile ); # file size $sentinfo = $cgi->uploadInfo( $sentfile ) ; fileparse_set_fstype( "MSDOS" ); # risky assumption? my ( $sentname ) = fileparse( $sentfile ); }

It's not perfect by any means, but it worked well and was a reasonably easy job--once I had merlyn's starting point.

In short, merlyn's article is very helpful, but you'll want to read the MIME::Lite docs pretty carefully and to experiment with the article's code to see how it works on your system.

Also, there are several other threads in the archives that offer alternative approaches and other information.

--f


In reply to Re: submit form data thru email by footpad
in thread submit form data thru email by quietone

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.