Page 1 of 1

mail() function

Posted: Tue Dec 19, 2006 3:29 pm
by sh33p1985
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?

Posted: Tue Dec 19, 2006 3:51 pm
by daedalus__
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.