quick question regarding the mail() function, ive drawn up a HTML template for an invoice in PHP (as data from a database is used to populate the invoice). on completion of an order id like to email the customer a copy of their invoice.
i was thinking the best way of acheiving this would be to require() the invoice template which generates the HTML code for the invoice and populates it with the customers order data and returns the entire HTML code as a variable.
e.g.
require "Templates/invoice.php";
*-----------------------------------------
//processing in invoice.php returns:
$invoice = "<table>........</table>"
*-----------------------------------------
mail($to, $from, $subject$, $invoice);
that seem like a pretty sound way of doing this?
mail() function
Moderator: General Moderators
- daedalus__
- DevNet Resident
- Posts: 1925
- Joined: Thu Feb 09, 2006 4:52 pm
First, please use
Code: Select all
,Code: Select all
, and [syntax] tags where they are appropriate.
It would be better to put the code that processes the invoice inside of a class or a function (if it is a small job) and call that rather than requiring a file.