mail() function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sh33p1985
Forum Commoner
Posts: 78
Joined: Thu Mar 11, 2004 9:22 am

mail() function

Post 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?
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post 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.
Post Reply