Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Attaching Files to E-mail

by She-wolf (Sexton)
on Sep 01, 2000 at 19:52 UTC ( #30740=note: print w/replies, xml ) Need Help??


in reply to Attaching Files to E-mail

Hmm, let me be a little more specific.

1. User fills out a form which includes their e-mail address and the path on their workstation/computer where the file is
2. File(s) specified are sent as an attachment and NOT stored on the website server

As for using the file upload section of CGI.pm, the author put warnings regarding several things I need to do:

1. Large files tend to fail for netscape servers(We use netscape and the file(s) are going to be very large)
2. For UNIX netscape the browser will hang, guess what we're on

Thanks again

She-wolf
"Wha? I don't get it."

Replies are listed 'Best First'.
RE: Re: Attaching Files to E-mail
by le (Friar) on Sep 01, 2000 at 20:28 UTC
    First, be sure that you define the FORM tag in your HTML like this:
    <form method=post enctype="multipart/form-data"> # multipart/form-data + is necessary for uploads ... <input type="file" name="file"> # This defines an upload field
    Processing the query then should be easy with MIME:Lite:
    # Create new Mail object. my $mail = MIME::LITE->new( From => $from, To => $to, Subject => $subject, Type => 'multipart/mixed' ); # 'Attach' text to it. $mail->attach( TYPE => 'TEXT', DATA => $messagebody ); # If we have an attachment, attach it. if ($q->param("file")) { my $upload = $q->upload; my $fh = $upload->fh; my @data; binmode $fh; local $_ = ''; while (read($fh, $_, 1024)) { push @data, $_; } close $fh; $mail->attach( Data => \@data, Filename => $upload->filename, Type => $upload->type ); } # Finally, send the mail. open (MAIL, "| /usr/sbin/sendmail -t -i") or die $!; $mail->print(\*MAIL); close MAIL;
RE: Re: Attaching Files to E-mail
by KM (Priest) on Sep 01, 2000 at 20:07 UTC
    We have pointed you to a variety of options. What exactly have you tried and failed? Did you try CGI.pm's upload and have it fail? IMO, a good thing to do it try what is readily available, suggested, and tested first. Then, if something doesn't work (browser hangs, files are too large, etc..) let us know and we can try to think up other ways. But, generally, nothing you are wanting to do can not be done with CGI.pm and MIME::Lite.

    Cheers,
    KM

RE: Re: Attaching Files to E-mail
by tenatious (Beadle) on Sep 01, 2000 at 20:14 UTC

    I don't really understand the purpose of this script. The user enters their own email address and the path to a file. The script then sends a copy of that file to the user's email address. Why?

    At any rate, it seems like the easiest solution would be to allow the user to open up a mail client (like messenger that comes with communicator in Linux) and attach files that way.

    Either you are going to have to get into the nitty gritty of how multipart forms send stuff and read it and fix some problems that even (bows head in reverence)Lincoln Stein has not solved yet, or you are going to have to allow the user to upload the file to the server.

    It'd be easier to write a web page with pretty pictures that would explain how to do this than to write a script that acts as a mediator.

      Sorry, I voted you --. Seems you never heard of Web based eMail-clients.

      Of course, the attachments get stored on the server, but only temporarily.

        Actually, I have, and I've actually written one or two. And I don't mind that you voted me down. I don't really care about the points.

        There appears to be a difference, though, or perhaps I'm not understanding the problem (entirely likely).

        (from the "clarification")

        1. User fills out a form which includes their e-mail address and the path on their workstation/computer where the file is
          I took this to mean that the user is sending the file to herself. Not to another.
        2. File(s) specified are sent as an attachment and NOT stored on the website server
          Note that it doesn't say... stored temporarily and then erased... it says not stored.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://30740]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2022-12-04 19:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?