We help IT Professionals succeed at work.
Get Started

fpdf application - sends email with attached pdf - need email to be secure

1,562 Views
Last Modified: 2012-06-21
my fpdf application sends form submissions as a pdf email attachment. the entire process is done using an ssl cert: https://midlandsortho.com/newpatientpacket/. i need the email itself and/or the pdf the be secure and/or encrypted.
....
$pdfcontent = $pdf->Output("helloworld.pdf", "S");

################################################################################
################################################################################
//output to e-mail 
//output to e-mail 


require_once('../fpdf/Mail.php');
require_once('../fpdf/Mail_Mime/mime.php');

// email address of the recipient
//$to = "mapa@midlandsortho.com";
//$to = "craigmusicelkins@gmail.com";
$to = "albertw@midlandsortho.com";





// email address of the sender
$from = "midlandspacket@healthpresence.com";


// subject of the email
$subject = 'Midlands Orthopaedics, p.a. - New Patient Packet:  '.$applicant;

// email header format complies the PEAR\'s Mail class
// this header includes sender's email and subject
$headers = array(       'From' => $from,
                                'Subject' => $subject,
                                'Cc' => "annm@midlandsortho.com");
								//'Cc' => "celkins@healthpresence.com, elkinhimer@sbcglobal.net");
								//'Cc' => "annm@midlandsortho.com",
								//'Cc' => "elkinhimer@sbcglobal.net");

// We will send this email as HTML format
// which is well presented and nicer than plain text
// using the heredoc syntax
// REMEMBER: there should not be any space after PDFMAIL keyword
$htmlMessage = <<<PDFMAIL
<html>
<body bgcolor="#ffffff">
<p align="left">
You have received this automated
mailing from www.midlandsortho.com.
Please do not respond to this email. This message
contains an attached New Patient Packet.
</p>
</body>
</html>
PDFMAIL;

// create a new instance of the Mail_Mime class
$mime = new Mail_Mime();

// set HTML content
$mime->setHtmlBody($htmlMessage);

// IMPORTANT: add pdf content as attachment
$mime->addAttachment($pdfcontent, 'application/pdf', 'New_Patient_Packet.pdf', false, 'base64');

// build email message and save it in $body
$body = $mime->get();

// build header
$hdrs = $mime->headers($headers);

// create Mail instance that will be used to send email later
$mail = &Mail::factory('mail');

// Sending the email, according to the address in $to,
// the email headers in $hdrs,
// and the message body in $body.
$mail->send($to, $hdrs, $body);

header ('Location: https://midlandsortho.com/newpatientpacket/thanks.php');

?>

Open in new window

Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE