http://www.perlmonks.org?node_id=216429

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

How can i send an email with attachment from an html form. Can any body give me the perl code and html form to do this
  • Comment on how can send an email with attachment from an html form

Replies are listed 'Best First'.
Re: how can send an email with attachment from an html form
by ph0enix (Friar) on Nov 29, 2002 at 09:36 UTC

    Email must be send directly from form? Your browser must be properly configured - main problem

    <form action='mailto:address@somewhere.com' method='post' name='myfrm' + enctype='multipart/form-data'> <input type='file' name='file1'> <input type='submit' name='submit' value='send email'> </form>

    I suggest to use perl script on server side.Web servers are usually properly configured, but web browsers not...

    <form action='emailsend.pl' method='post' name='myfrm' enctype='multip +art/form-data'> ...

    For simple sending email with attachement is usable high level module Mail::Sender

Re: how can send an email with attachment from an html form
by Anonymous Monk on Feb 17, 2020 at 21:22 UTC
    This is exactly what I'm looking for, but it's not working on my site. Where do I place the 2nd part of this code?

      This thread is very old. I'd suggest looking at MIME::Lite for your email sending needs.

        Um, from the doc for MIME::Lite (for several years now):

        MIME::Lite is not recommended by its current maintainer. There are a number of alternatives, like Email::MIME or MIME::Entity and Email::Sender, which you should probably use instead. MIME::Lite continues to accrue weird bug reports, and it is not receiving a large amount of refactoring due to the availability of better alternatives. Please consider using something else.


        The way forward always starts with a minimal test.