Send PDF Attachment

By Toledoh - October 24, 2016

Hi Guys.

I'm trying to use the following.  It allows a user to submit an email address which then sends an email to that address.  The core works fine, but how do I attached a PDF of the current page to that email using the createPDF plugin?

// process form
if (@$_REQUEST['submitForm']) {

// error checking
$errorsAndAlerts = "";
if (!@$_REQUEST['email']) { $errorsAndAlerts .= "You must enter an email to send to<br/>\n"; }

if (!$errorsAndAlerts) {

// Send Admin Alert via Email Template
$emailHeaders = emailTemplate_loadFromDB(array(
'template_id' => 'EMAIL-REPORT-FORM',
'placeholders' => array(
'user.email' => $_REQUEST['email'],
'user.comment' => $_REQUEST['message'],

'attachments' => array(
'sample.pdf' => createPDF_fromHTML('<h1>HTML As Inline</h1>')
),

)));
$mailErrors = sendMessage($emailHeaders);

//
$errorsAndAlerts = "Thanks! We've sent your email.";
$_REQUEST = array(); // clear form values
}
}

Cheers,

Tim (toledoh.com.au)

By Toledoh - October 25, 2016

That makes sense - thanks Dave.

NB.  I'm guessing 

What I'd recommend instead is putting the content of the page in an include

Cheers,

Tim (toledoh.com.au)

By Dave - October 25, 2016

Yes, thanks!  (I fixed the original post)

Dave Edis - Senior Developer
interactivetools.com