Page 1 of 1

Sending an email through mail( ) function

Posted: Mon Mar 02, 2009 6:19 am
by becky-atlanta
A html and a text file was generated and . When I tried to put $order_file in $message, it gave me error. How can I put the content of a text file in $message and email it?

This is the code I tested and it worked:

<?php
$order_file = $_POST["orderfile"];

$to = "someone@test.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message./n";
$from = "Elegant Essen Catering";
$headers = "From: $from";
mail($to,$subject,$message,$headers);

echo "Mail Sent.";

Re: Sending an email through mail( ) function

Posted: Mon Mar 02, 2009 1:06 pm
by php_east
function file_get_contents

Code: Select all

 
<?php
$order_file = $_POST["orderfile"];
$message = file_get_contents($order_file);
 
the order file must exist and correctly placed. you would need to process the $_POST to ensure this is so.

Re: Sending an email through mail( ) function

Posted: Mon Mar 02, 2009 8:32 pm
by becky-atlanta
php_east,

Thanks for the tips. I processed the order form to a unique html file. When the customer click "Confirm Order", the next process was to send the order in html format to the company. It works like magic!! :lol:

THANK YOU!