Avatar of phillystyle123
phillystyle123
Flag 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

PHPWeb DevelopmentWeb Services

Avatar of undefined
Last Comment
phillystyle123

8/22/2022 - Mon
svgmuc

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
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
svgmuc

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
phillystyle123

ASKER
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!
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck