Ian N wrote:[color=blue]
> Hi,
>
> I'm creating a site that posts orders to an email address when they're
> submitted, these orders need to be in the form of official invoices so
> i'm using HTML to format them.
>
> I already have a shopping basket system which adds all of the totals
> up and puts them into a nice looking invoice.
>
> What's the best way to take this HTML and put it into an email?
> I'm really looking for a way of sending the page via email, like you
> can do in IE by selecting File > Send > Page by Email.
>
> The basket script is quite large and i'm trying to avoid running it
> more times than neccesary.
>
> Any advice would be greatly appreciated.[/color]
This depends on a few things. Will your cart be printing each invoice
to a static HTML file, or will it be displaying a dynamic page?
This is the basics for doing it from a static page:
-if it's in a static HTML file. Use file() function to read the file
into an array by line number.
-Use foreach() statement to iterate the array into a string
-use the mail() function to send the email.
<?php
$message = "";
foreach(@file($fileLocation) as $lineText) {
$message .= $lineText . "\n";
}
mail($to,$subject,$message,$additional_headers) or die("Message
didn't send");
?>
The basics of doing it from a dynamic page:
-set up your cart to write the invoice to a string variable. This can
be quite difficult to do, but you'll have to read through the code, and
then use that string variable in the mail() function.
References:
Filesystem Functions =>
http://www.php.net/manual/en/ref.filesystem.php
mail() Function =>
http://www.php.net/manual/en/function.mail.php
--TekWiz