Link to home
Start Free TrialLog in
Avatar of phillystyle123
phillystyle123Flag for United States of America

asked on

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

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

Avatar of svgmuc
svgmuc
Flag of United States of America image

I believe GPG is a way to go...

This article shows how to use it and how to do it in/from PHP:

http://devzone.zend.com/article/1265
Avatar of phillystyle123

ASKER

thanks for the help - just got more clarification from the client - they're looking to actually password protect the pdf attachment - any ideas?
ASKER CERTIFIED SOLUTION
Avatar of svgmuc
svgmuc
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
that did the trick! you just download the zip, upload fpdf_protection.php to you fpdf directory then modify these 2 lines:

require('fpdf_protection.php');

$pdf=new FPDF_Protection();

thanks!