Current Path :
/
home
/
zrcdevco
/
public_html
/
zrc-email-program
/
Or
Select Your Path :
Upload File :
New :
File
Dir
/home/zrcdevco/public_html/zrc-email-program/zrc_pdf_email.php
<?php require('fpdf16/fpdf.php'); require('fpdf-with-letter.php'); // Mail and Mail Mime installed in PEAR libraries require_once('Mail.php'); require_once('mime.php'); function create_mail_pdf($text_file_name,$replace_array,$fax_number,$test_email=NULL) { // Use FPDF and PEAR Mime mail to create and send a PDF attchment. $pdf=new PDF(); $pdf->AliasNbPages(); $pdf->SetMargins(20, 0, 20); $pdf->AddPage('P', 'Letter'); $pdf->SetFont('Times','',12); $pdf->LetterBody($text_file_name,$replace_array); $pdf_file_name = "$fax_number.pdf"; $pdfcontent = $pdf->Output($pdf_file_name,'S'); echo "<br />$pdf_file_name Created."; // To with fax number for Ringcentral FAX $to = "$fax_number@rcfax.com"; if (isset($test_email)) $to = "$test_email"; // email address of the sender $from = "zrcfax@trionia.com"; // subject of the email $subject = ""; // email header format complies the PEAR's Mail class // this header includes sender's email and subject $headers = array('From' => $from, 'Subject' => $subject); // REMEMBER: there should not be any space after PDFMAIL keyword // create a new instance of the Mail_Mime class $mime = new Mail_Mime(); // set empty HTML content $mime->setHtmlBody(''); $content_type = "Application/pdf"; // Content type of the file // IMPORTANT: add pdf content as attachment $mime->addAttachment($pdfcontent, 'application/pdf', $pdf_file_name, false, 'base64'); // Add Galvilite PDF as an attachment $file = "GALVILITE_3_07_fax.pdf"; // Content of the file $file_name = "GALVILITE_3_07_fax.pdf"; // Name of the Attachment $mime->addAttachment ($file, $content_type, $file_name, 1); // Add the attachment to the email // 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. return $mail->send($to, $hdrs, $body); } ?>