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

I have a form processing script that will take user input from an HTML form and email it to me and it is using NET::SMTP. Up untill now it has been working perfectly fine but now I want users to be able to email certain files types (mainly images, zip files, and basic text files) to me. I have been doing some digging and see that there are a few modules that can do this but have not seen anything for NET::SMTP. Can NET::SMTP send attachments or is there a module that I can add to my script to handle just the attachments and not have to rewrite the entire thing?

Replies are listed 'Best First'.
Re: Attachments with NET::SMTP
by planetscape (Chancellor) on Dec 26, 2005 at 10:06 UTC
Re: Attachments with NET::SMTP
by john_oshea (Priest) on Dec 26, 2005 at 10:16 UTC
Re: Attachments with NET::SMTP
by gbarr (Monk) on Dec 26, 2005 at 21:18 UTC
    Net::SMTP implements the SMTP protocol, so it can send attachements. You just have to format the body and headers correctly. There are a few modules on CPAN that can help you do this. I suggest looking at MIME::Lite
      I have decided to rewrite the script using MIME::Lite, but do you know if this will let internet users email files from there local computer to me?

        You can set up your web script in that way, but it seems an awfully roundabout and wasteful way to transfer files. Why don't you just have the user upload the file to the server where you can access it after receiving the email (you could put the file path into the generated email)? Transferring files via email has a few problematic aspects, most ISPs these days block certain attachment file types for example, so why do it unneccessarily?


        A computer is a state machine. Threads are for people who can't program state machines. -- Alan Cox
Re: Attachments with NET::SMTP
by Anonymous Monk on Dec 27, 2005 at 05:34 UTC
    I was looking at the MIME module and figured that is what I need but was hoping not to have to rewrite the entire script. It took me 2 weeks writting this one to get it working with the latest standerds, but it looks like I am going to have to either figure out another way for people get there attachments to me or rewrite my script. Thanks for the help.