Sending an email through 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
User avatar
becky-atlanta
Forum Commoner
Posts: 74
Joined: Thu Feb 26, 2009 6:26 pm
Location: Atlanta, GA

Sending an email through mail( ) function

Post 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.";
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: Sending an email through mail( ) function

Post 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.
User avatar
becky-atlanta
Forum Commoner
Posts: 74
Joined: Thu Feb 26, 2009 6:26 pm
Location: Atlanta, GA

Re: Sending an email through mail( ) function

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