Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8452621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:32:52+00:00 2026-06-10T11:32:52+00:00

I have an online PDF form which a user completes and then clicks a

  • 0

I have an online PDF form which a user completes and then clicks a submit button which sends the form to an email address as an attachment and also stores the data in a database. However the completed individual field values do not appear when sent to an email address. How can I achieve this? many thanks.

//define the receiver of the email 
$to = 'test@*****.com'; 
//define the subject of the email 
$subject = 'Completed PDF form'; 
//create a boundary string. It must be unique 
//so we use the MD5 algorithm to generate a random hash 
$random_hash = md5(date('r', time())); 
//define the headers we want passed. Note that they are separated with \r\n 
$headers = "From: noreply@test.com\r\nReply-To: noreply@test.com"; 
//add boundary string and mime type specification 
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\""; 
//read the atachment file contents into a string,
//encode it with MIME base64,
//and split it into smaller chunks
$attachment = chunk_split(base64_encode(file_get_contents('purchase_order_form.pdf'))); 
//define the body of the message. 
ob_start(); //Turn on output buffering  
?> 
--PHP-mixed-<?php echo $random_hash; ?>  
Content-Type: multipart/alternative; boundary="PHP-alt-<?php echo $random_hash; ?>" 

--PHP-alt-<?php echo $random_hash; ?>  
Content-Type: text/plain; charset="iso-8859-1" 
Content-Transfer-Encoding: 7bit

Hello World!!! 
This is simple text email message. 

--PHP-alt-<?php echo $random_hash; ?>  
Content-Type: text/html; charset="iso-8859-1" 
Content-Transfer-Encoding: 7bit

--PHP-alt-<?php echo $random_hash; ?>-- 

--PHP-mixed-<?php echo $random_hash; ?>  
Content-Type: application/zip; name="purchase_order_form.pdf"  
Content-Transfer-Encoding: base64  
Content-Disposition: attachment  

<?php echo $attachment; ?> 
--PHP-mixed-<?php echo $random_hash; ?>-- 

<?php 
//copy current buffer contents into $message variable and delete current output buffer 
$message = ob_get_clean(); 
//send the email 
$mail_sent = @mail( $to, $subject, $message, $headers ); 
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" 
echo $mail_sent ? "Mail sent" : "Mail failed"; 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:32:53+00:00Added an answer on June 10, 2026 at 11:32 am

    Here is your example using Swiftmailer, you will see that it’s really easier !

    require_once '/path/to/swift-mailer/lib/swift_required.php';
    
    // Create the Transport
    $transport = Swift_MailTransport::newInstance();
    
    // Create the Mailer using your created Transport
    $mailer = Swift_Mailer::newInstance($transport);
    
    // Create the message
    $message = Swift_Message::newInstance()
    
      // Give the message a subject
      ->setSubject($subject)
    
      // Set the From address with an associative array
      ->setFrom(array('noreply@test.com'))
    
      // Set the To addresses with an associative array
      ->setTo(array($to))
    
      // Give it a body
      ->setBody($message)
    
      // Optionally add any attachments
      ->attach(Swift_Attachment::fromPath('purchase_order_form.pdf'))
      ;
    
    // Send the message
    $result = $mailer->send($message);
    
    echo $mail_sent ? "Mail sent" : "Mail failed"; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to fill a pdf form (used to submit data online) which is
I have a working form which sends emails from the default logged in account.
I am working on online pdf library project. In this I have a feature
I have a online shopping cart, at checkout user enters his zipcode. There are
I have an online service which uses a java applet to perform client side
I have been learning windows API from online and PDF books but I hear
I'm trying to make a dynamic PDF form using Adobe LiveCycle designer and have
I am researching filling out a form programatically. I have seen this question which
I have a field on a PDF form that could be too small for
I need to create an online viewer which converts PDF files into browsable images,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.