RE: compose html body with variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Matt [mailto:mlist@xxxxxxxxxxx]
> Sent: 06 August 2007 15:38
> To: php-general@xxxxxxxxxxxxx
> Subject:  compose html body with variables
>
>
> Hello,
>
> I'm trying to compose the body of an html email to use with the mail()
> function.  I'm running into problem because I'm not sure how to quote
> the multi-line body.  Here is what I have:
>
> $body = "
>                echo "Hello, here is your quote from Freight Services.<br
> /><br />";
>                echo "Shipping from: <tab> $origin to $destination<br />";
>                 echo "<br>";
>                 echo "Shipping subtotal $" . number_format($subtotal,2);
>                 echo "<br>";
>                 echo "<br>";
>                 echo "Freight charges $" .
> number_format($freightCharges,2);
>                 echo "<br>";
>                 echo "Fuel surcharge $" . number_format($fuelSurcharge,2);
>                 echo "<br>";
>                 echo "Pickup and delivery $" .
> number_format($pickupDelivery,2);
>                 echo "<br>";
>                 echo "<br>";
>                 echo "Miscellaneus costs (e.g. liftgates, etc.) below $"
> . number_format($miscCost,2);
>                 echo "<br>";
>                 echo "<br>";
>                 if ($liftgatePickup == "50"){
>                         echo "Adding liftgate on pickup $50.00";
>                         echo "<br>";
>                 }
>                 if ($liftgateDelivery == "50"){
>                         echo "Adding liftgate on delivery $50.00";
>                         echo "<br>";
>                 }
>                 if ($spectimeDelivery == "35"){
>                         echo "Adding cost of specific-time
> delivery $35.00";
>                         echo "<br>";
>                 }
>                 if ($conventionDelivery == "35"){
>                         echo "Adding cost of convention delivery $35.00";
>                         echo "<br>";
>                 }
>                 if ($dreyageWait != 0){
>                         echo "Adding cost for wait $" . $dreyageWait;
>                         echo "<br>";
>                 }
>                 if ($insideDelivery == "25"){
>                         echo "Adding cost for inside delivery $25.00";
>                         echo "<br>";
>                 }
>                 if ($notifyClient == "10"){
>                         echo "Adding cost for client notification $10.00";
>                         echo "<br>";
>                 }
>                 echo "Total cost is $" . number_format($totalcost,2);
>                 echo "<br /><br />";
>
>                 echo "<a href=\"www.foo.net\">foo Services</a>";
>
>
>                $subject = "Online Freight Quote";
>
>                mail($email, $subject, $body, "From:
> info@xxxxxxx\r\nReturn-Path: foo@xxxxxxxxxxxxxxxxxxx\r\nReply-To:
> info@xxxxxxx\r\nX-Mailer: PHP 4.x\r\nMIME-Version: 1.0\r\nContent-Type:
> text/html; charset=iso-8859-1\r\n");
>
> If anyone could assist me I'd appreciate it very much,
>
> Matt
>

Hi Matt,

The problem here is that you're using echo statements, which output
directly. Instead you need to build a string containing this output, for
example:

$body = "Hello, here is your quote from Freight Services.<br /><br />";
$body .= "Shipping from: <tab> $origin to $destination<br />";

etc.

Note the use of the .= operator. This is the same as saying $body =
$body.'whatever';

At the end, $body will then contain the HTML body of your email which you
pass to the mail function.

Hope this helps,
Edward

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux