Mail Attachments (from dynamic PDF)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Mail Attachments (from dynamic PDF)

Post by icesolid »

Is there anyway to take a dynamically created PDF (I use http://html2fpdf.sourceforge.net/) and attach that to an e-mail?

I know how to add an attachment to a e-mail using mail();, I am just not sure how to take this dynamically created PDF file and attach it to a e-mail. Maybe save the file in a temp directory?
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: Mail Attachments (from dynamic PDF)

Post by JAB Creations »

I would imagine you'd want to create the file on the server with a unique name.pdf (maybe the name matches the session id?), attach it after it's created, and then delete the file after the email is sent? I'm not sure how it would be coded though I comprehend the steps you seem to be missing. There may also be other methods of achieving this goal though hopefully this will spark some ideas that may help you produce something that will lead you to your goal. Good luck! :)
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Re: Mail Attachments (from dynamic PDF)

Post by icesolid »

I am just stuck on the part where I take that dynamically generated PDF and save it to a temp directory.

The PDF gets dynamically created like so; create_pdf.php?id=10000

I can't figure out how to take that and save it to a file.
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Re: Mail Attachments (from dynamic PDF)

Post by icesolid »

I take that back, I have figured it out.
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: Mail Attachments (from dynamic PDF)

Post by flying_circus »

Good! :mrgreen:

I was going to add that I've got a similar script. When emailing, the PDF gets saved to a temp directory and then deleted once the email is sent.
Post Reply