I'm trying to send an fpdf file to phpmailer while the hyperlink is clicked. Currently the hyperlink only opens the pdf file. How do I attach it with the phpmailer?
HYPERLINK THAT OPENS THE PDF
<a target="_blank" href="<?php echo SITEURL; ?>/mod/orders/x-SOprint_new.php?id=<?php echo $d['orderID']; ?>"><?php echo $d['orderID']; ?></a>
PHPMAILER CODE
<?php
require 'phpmailer/PHPMailerAutoload.php';
session_start();
$orderID=$_SESSION['orderID'];
$tomailID=$_POST['tmail'];
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = "ssl://smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "";
$mail->Password = "Password";
$mail->SetFrom("");
$mail->Subject = "mail test for last time";
$mail->Body = "Respected Sir/Madam"
. "Thanks for your Order"
. "The Sales Order Number:"+$orderID+" Date : ,"
. "Sales order Copy Atached in PDF format"
. "\n"
. '\n'
. "\n"
. "This is computer generated Letter , Please do not reply on this Address";
$mail->AddAddress("$tomailID");
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent"+$tomailID;
}
?>
FPDF FILE
<?php
$pdf = new FPDF();
global $DB;
$view=$_REQUEST['vbeln'];
require("fpdf/fpdf.php");
$sql = "SELECT * FROM `" . $DB->pre . "party_outstanding_history` WHERE BELNR= '". $view ."'";
$rows = $DB->dbRow($sql);
$custCode= $rows['KUNNR'];
$docDate= $rows['AUGDT'];
$sql1 ="SELECT * FROM `" . $DB->pre . "party_master` WHERE KUNNR = '". $custCode."'";
$rows1 = $DB->dbRow($sql1);
$partyname = $rows1['NAME1'];
$pdf->AddPage();
$pdf->Rect(5, 5, 200, 287);
$pdf->SetFont('helvetica','B',12);
$pdf->Text(90,15,'JHAMPSTEAD DIVISION',1,2,'C');
$pdf->Text(70,20,'DEBIT/CREDIT NOTE',1,2,'C');
$pdf->SetFont('helvetica','',10);
$pdf->Text(10,35,'Doc No :',1,2,'C');
$pdf->Text(120,35,'Doc Date :',1,2,'C');
$pdf->Text(10,40,'Customer :',1,2,'C');
$pdf->Text(10,45,'Customer Name :',1,2,'C');
$pdf-> Ln();
$pdf->Text(10,60,'Agent :',1,2,'C');
$pdf->Text(10,65,'Reference :',1,2,'C');
$pdf->Text(10,70,'Text :',1,2,'C');
$pdf-> Ln();
$pdf->SetFont('Arial','B',9);
$pdf->SetXY(11,103);
$pdf->Cell(25,7,'BILL NO.',1,0,'L',0);
$pdf->Cell(22,7,'DATE',1,0,'L',0);
$pdf->Cell(22,7,'AMOUNT',1,0,'L',0);
$pdf->Cell(18,7,'LDAYS',1,0,'L',0);
$pdf->Cell(18,7,'EP1',1,0,'L',0);
$pdf->Cell(18,7,'EP2',1,0,'L',0);
$pdf->Cell(22,7,'INTDR1',1,0,'L',0);
$pdf->Cell(22,7,'INTAMT',1,0,'L',0);
$pdf->Cell(18,7,'NET',1,0,'L',0);
$pdf-> Ln();
$pdf-> Ln();
$pdf->SetX(11);
$pdf->Cell(47,7,'TOTAL',1,0,'L',0);
$pdf->Cell(22,7,'',1,0,'L',0);
$pdf->Cell(18,7,'',1,0,'L',0);
$pdf->Cell(18,7,'',1,0,'L',0);
$pdf->Cell(18,7,'',1,0,'L',0);
$pdf->Cell(22,7,'',1,0,'L',0);
$pdf->Cell(22,7,'',1,0,'L',0);
$pdf->Cell(18,7,'',1,0,'L',0);
$pdf->Ln();
$pdf->SetX(156);
$pdf->Cell(22,7,'Net Amt.',1,0,'L',0);
$pdf->Cell(18,7,'',1,0,'L',0);
$pdf->SetFont("Arial","B","8");
$pdf->SetXY (5,271);
$pdf->Output();
?>