Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Best practice for sending results to a user via email

by bitingduck (Chaplain)
on Apr 23, 2015 at 05:01 UTC ( #1124366=note: print w/replies, xml ) Need Help??


in reply to Best practice for sending results to a user via email

This is a fairly common practice in sites that generate custom PDFs. I've seen it for book purchases that apply a watermark to the book so it's got your name on it and also on proposal sites where part of submitting a proposal is to generate a pdf from the submitted materials.

Exactly how you do it depends on the level of security you want for the content generated for the user. The easiest and least secure is to generate a file, write it to the webserver in a place that's accessible to all visitors and then send a link to the user with Mail::Sendmail. You can obfuscate things a little by using a hash function to generate unique and unpredictable filenames and not allowing the directory to be listed, but it's still relatively insecure.

More secure is to generate the file and store it someplace that your scripts are allowed to read, but isn't accessible in the webserver directory structure. Then you generate the file and store it in the storage directory and record that location in a database. You also create a URL that you store in the same directory database (or that lets you figure out where you stored the user's file, e.g. a url that calls http://example.com/cgi/downloader.pl?file="customdownload.pdf") send the link and a nice note. Then when the user calls your website with that URL it executes the script that passes them the file. If you want it to be secure, you require the user to be logged in to get the file.

  • Comment on Re: Best practice for sending results to a user via email

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1124366]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2018-01-17 18:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (203 votes). Check out past polls.

    Notices?