Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically create PDFs and email them

I've got a registration list, which I need to send out a PDF to each person on the list. Each email needs to contain a PDF, which has a base version on the server, but each person's needs to be personalized via name/company etc over the top. This needs to be emailed to each person, which at the moment adds up to be 2,500, but can easily be much higher in the future.

I've only just started working on this project, but the problem I've encountered continuously since last week are that the server doesn't seem to be able to handle doing this. Currently the script is using Zend, which then allows it to use Zend_Pdf and Zend_Mail to create and email the PDFs. Zend_mail connects to an smtp server from smtp.com to do the actual emailing.

Since we have quite a few sites running on the server, we can't afford it to be going down, and when I run it in batches it can start to go down. The best solution I have thus far is running curl from my local machine to the script, which then does one person. The curl script then calls it again, over and over in batches. Even this runs into problems at times, and seems to some how hog memory even after it should be complete (I'm really not sure how).

So what I'm looking for is information on doing this, from libraries, code, information on server setups, anything that can make this much less painful, and much quicker for us to run. I've run out of ideas, and this is something I've not really had to do before (especially at a bulk level).

Thank you.

Edit:

I also forgot to mention that it's using zend_barcode::factory for creating a barcode on the PDF.

like image 486
Scott Flack Avatar asked Aug 09 '26 20:08

Scott Flack


1 Answers

First step I suggest is to work out where the problem lies if you can. Is it the PDF generation? Is it the emailing? "Server doesn't seem to be able to handle this" doesn't say what is actually failing as with the "server goes down" - you need to determine if you are running out of memory/disk-space/time or something else. That will help you determine if you need a tweak or a new approach to your generation. Because you said that even single manual invocations can fail you should be able to narrow the problem down to exactly what is the cause of the failure.

If you are running near some resource limit (which might be the case with several sites running), you probably need to offload this capability onto another machine. Your options include:

  1. run the same setup on a new host and adjust your applications to use the new system
  2. run a new setup on a new host
  3. use an external system (such as the mentioned PDFCrowd or Docmosis)

Start with the specifics of the problem. I hope that helps. Please note I work for the company that created Docmosis.

like image 185
Paul Jowett Avatar answered Aug 12 '26 10:08

Paul Jowett



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!