Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Adobe Acrobat Form Mail Script Acting Strangely

Posted on 2004-05-02
Medium Priority
Last Modified: 2013-12-13
I am using the below PHP script to have my Adobe Acrobat Forms send to me fully completed by the client.  The problem is the redirect page once the script is done ***Header("Location: http://www.sovereignfunding.com/funding/fqty.html"***  hangs for a very long time and often times out.

If you type in http://www.sovereignfunding.com/funding/fqty.html there is never a problem so I am not sure what the issue is.

Looking forward to hearing from someone.

Thanks in advance!


// $form_name is provided in the url that calls this page, allowing this page
// to be called from different PDF's, yet customized for each one
$date = (date ("m/d/y"));
$time = (date ("H:i:s T"));
$tmpname = (date ("mdy-His"));

$message = '
This is a multi-part message in MIME format.

Content-Type: text/plain;
Content-Transfer-Encoding: 7bit

A '.$form_name.' was submitted from the sovereignfunding.com website at '.$time.' on '.$date.'.

(attachment: '.$form_name.')

Content-Type: application/vnd.fdf;
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;




$recip = "funding_quote@sovereignfunding.com";
$subject = $form_name;
$headers = "From: SMFG <Funding_Quote@SovereignFunding.com>\n";
$headers .= "Return-Path: <Info@SovereignFunding.com>\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"----=_NextPart_000_0007_01C37EC6.3F062EA0\"\n";

$status = mail($recip, $subject, $message, $headers);

Header("Location: http://www.sovereignfunding.com/funding/fqty.html");
Question by:d_springer
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6

Expert Comment

ID: 10978949
Well, This is a tough one, but perhaps it has to do with your mail() function taking a long time as the script will need to do that before sending the redirect header.

You may try using instead of the mail function, the pear mail class, this way you can switch from SMTP or sendmail methods to see if one works better than the other.

I think on windows, you're restricted to SMTP method anyway, so it may not help in that case.

If you have a Un*x box, you can sniff the connection and see if it hangs before the http location header appears, or after. This would help you distinquish.

If you don't have this tool, you can make the form URL available and I can take a look if you'd like.

Author Comment

ID: 10979555

I am script-stupid so I can tell you this much.

I am on a Linux machine and my form url is here: http://www.sovereignfunding.com/FDFMail.php
A txt version can be found here: http://www.sovereignfunding.com/FDFMail.php.txt

My FormMail script can be found here: http://www.sovereignfunding.com/cgi-bin/FormMail.pl

I am not sure how to "sniff the connection" or what the "the pear mail class" is.

Your guidance in troubleshootting this is greatly appreciated!


PS - Where can I find the "tool" you mentioned?

Expert Comment

ID: 10981762
There's a bunch of software out there that can be used for sniffing connections, I use a commandline tool called ngrep, not nessasarily because it's the best, but because I've been pretty successful at using it, and it' fast.. makes sense to me, etc..

You can get it here: http://ngrep.sourceforge.net/

I went to the URL's you gave me and the whole transaction completed in
0.174816 seconds, so no timeout there. I didn't get a form at all, so perhaps the results are different with actual information?

What does the formmail.pl script have to do with this?
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 10981856
To run the application in its entirety you need to start at one of my Adobe Acrobat forms: https://www.sovereignfunding.com/funding/Business_Note.pdf

Once you submit the Adobe Acrobat form at the bottom of the page FDFMail.php is run and this is when the redirect page tends to hang.

The page doesn't hang when you run it directly using http://www.sovereignfunding.com/FDFMail.php although I still receive an email along with a blank Adobe Acrobat attachment.

Re: FormMail.pl I thought when you mentioned "pear mail class" it might have something to do with FormMail.pl.

I went to http://ngrep.sourceforge.net/.  Do I install this directly on my server?  If yes should I install it to the root directory?

Thanks an sorry for all the stupid question etc.



Expert Comment

ID: 10982141
Well, I tried the form a couple of times and I never experienced a lag. Took 0.015 secs the second time. You should have the emails with lots of asdf's in them. That's me.

So, if it's not lagging for me, that means the script is okay at least. Maybe something with your unit? Try rebooting, upgrade Acrobat, etc..

Hope that helps. This looks like a tough one.. Try it from a different computer to see if it works.


Author Comment

ID: 10982169
I got the emails but the attachment said the file was damaged......

Expert Comment

ID: 10982287
Your method of creating the FDF data isn't like anything I've seen. Usually it's a little more structured, but I was figuring you knew something I didn't..

Here's the function I use:

function output_fdf($pdf_file, $pdf_data) {
      header ("Content-Type: application/vnd.fdf");
      $fdf = "%FDF-1.2\n%‚„œ”\n";
      $fdf .= "1 0 obj \n<< /FDF ";
      $fdf .= "<< /Fields [\n";
      foreach ($pdf_data as $key => $val) {
      $fdf .= "<< /V ($val)/T ($key) >> \n";
      $fdf .= "]\n/F ($pdf_file) >>";
      $fdf .= ">>\nendobj\ntrailer\n<<\n";
      $fdf .= "/Root 1 0 R \n\n>>\n";
      $fdf .= "%%EOF";
       print $fdf;

Use: output_fdf("http://www.yoursite.com/yourpdf.pdf", $data);

Where $data is an array:

$data = array (
      fieldname1 => 'fielddata1',
      fieldname2 => 'fielddata2',

That may work better as you're just passing the post vars if I remember, I'm not sure that will work.


Author Comment

ID: 10982354
My website contains many pdf documents each having hundreds of fields. https://www.sovereignfunding.com/funding/fquote.html

The current setup doesn't force me to name the specific documents or fields.

Can you think of a way to delay the redirect page request within the script?


Accepted Solution

Warble earned 1000 total points
ID: 10982405
Delay it? The sleep function will pause a script's execution: http://us4.php.net/sleep

You might very well have all those fields, but if your current method doesn't work, you gotta do it in a way that does. (I'm assuming it still doesn't work..)

Besides, any array will work, you can call the function like this:

output_fdf("http://www.yoursite.com/yourpdf.pdf", $_POST);

That would call it with all the field names in the previous form.

Author Comment

ID: 10982720

Thanks for all your help.

Can you do me a HUGE favor and change your script so that my current PDF docs located here: https://www.sovereignfunding.com/funding/fquote.html

are emailed to me here: funding_quote@sovereignfunding.com as an attachment.

I am not being lazy I simply don't have a clue when it comes to scripts.  Please include the <?php & ?> & the redirect to http://www.sovereignfunding.com/funding/fqty.html.

I need the script to be idiot proof otherwise I'll be right back here whining that I got some sort of error.



Author Comment

ID: 10983179

I changed

Header("Location: http://www.sovereignfunding.com/funding/fqty.html");


header( 'refresh: 1; url=/funding/fqty.html' );

And everything seems to be working fine.

Thanks for your help.


Expert Comment

ID: 10983446
Glad you figured it out. I'm going to have to look into your FDF method. Apparently it works, which is news to me. Thanks for teaching me something too!

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question