Q:

Send Acknowledgement In Mail

I am working on a payment gateway after completion of user payment, I am sending the user on success page where a acknowledgement is showing. 
Now I want to send this acknowledgement in user mail so that user can download it from email. So Any idea how can i done it. 
Thanks

A:

You can display the page confirming the order as well as get PHP to send the user an email,
You can get PHP to send a HTML email as follows:
$to      = $email;
$subject = 'Order Confirmed';
$message = '<html>This is an email to confirm that '.$OrderID.'  has been acknowledged.</html>';

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . " \r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . " \r\n";

// Additional headers
$headers .= 'From: Website <noreply@mysite.com>' . " \r\n";

mail($to, $subject, $message, $headers);

To attached a PDF document, the best way is to generate it with FPDF. 
You can then attach the PDF to the email which is automatically sent. 
$to     = $email;
$subject = 'Order Confirmed';
$message = '<html>This is an email to confirm that '.$OrderID.'  has been acknowledged.</html>';

// attachment name
$InvoiceFilename = "Invoice$OrderID.pdf";

// encode data (puts attachment in proper format)
$pdfdoc = $pdf->Output("", "S");
$pdf->Output(F,'../uploads/Invoice'.$OrderID.'.pdf'); 

//$pdf->Output();
$attachment = chunk_split(base64_encode($pdfdoc));

// main header
$headers  = "From: ".$from.$eol;
$headers .= "MIME-Version: 1.0".$eol; 
$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\""; 

// no more headers after this, we start the body! // 

$body = "--".$separator.$eol;
$body .= "Content-Transfer-Encoding: 7bit".$eol.$eol;
$body .= "This is a MIME encoded message. ".$eol;

// message
$body .= "--".$separator.$eol;
$body .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
$body .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$body .= $message.$eol;

// attachment
$body .= "--".$separator.$eol;
$body .= "Content-Type: application/octet-stream; name=\"".$InvoiceFilename. "\"".$eol; 
$body .= "Content-Transfer-Encoding: base64".$eol;
$body .= "Content-Disposition: attachment".$eol.$eol;
$body .= $attachment.$eol;
$body .= "--".$separator."--"; 

// send message
mail($to, $subject, $body, $headers);

