I cannot seem to get attachments to send through PHPMailer. Here is what I have for the code to send the email :
REVISED Automailer Content:
if(isset($_POST['type']) && $_POST['type'] == 'sendEmail' ){
require_once 'phpMail/PHPMailerAutoload.php';
$email = $_POST['email'];
$uuid = $_POST['uuid'];
$file_content = file_get_contents(BASE_PATH.'email.php?uuid='.$uuid);
$pdf_content = file_get_contents(BASE_PATH.'pdf.php?uuid='.$uuid);
$mail = new PHPMailer;
$mail->From = ADMIN_EMAIL;
$mail->FromName = SENDER_NAME;
$mail->addAddress( $email ); // Name is optional
$mail->addReplyTo(REPLY_EMAIL, 'Reply Mail');
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Email From '.User;
$mail->Body = $file_content;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->AddStringAttachment($output, attach.pdf);
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo "true";
}
exit;
}
REVISED Dompdf Code(pdf.php)
$html .= //Content Here
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$canvas = $dompdf->get_canvas();
$canvas->page_script('
if ($PAGE_NUM > 1) {
$font = Font_Metrics::get_font("helvetica", "bold");
$current_page = $PAGE_NUM-1;
$total_pages = $PAGE_COUNT-1;
$pdf->text(522, 770, "Page: $current_page of $total_pages", $font, 10, array(0,0,0));
}
');
$output = $dompdf->output();
file_put_contents('Attachment.pdf', $output);
If I remove the code concerning the attachment, the email sends just fine(with email.php in the body). Attachments, however refuse to work...