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.


In reply to Re: Best practice for sending results to a user via email by bitingduck
in thread Best practice for sending results to a user via email by Anonymous Monk

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.