Hi,
When a user enquires about a product, I want 1 email to be sent to the seller with the below information attached to the email ($recipient, $subject, $body, $headers), but I also want an invoice style email to be sent to the buyer with slightly different content in the $body. How do I send emails to 2 different people with different $body content?
Thanks
<?php
$recipient = "email@domain.com";
$product = $_POST['product'];
$model = $_POST['model'];
$code = $_POST['code'];
$price = $_POST['price'];
$productID = $_POST['productID'];
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$enquiry = $_POST['enquiry'];
$subject = "Website Enquiry about $model";
$body = "
Product Details: \n
Product Brand: \t $product \n
Product Model: \t $model \n
Product Code: \t $code \n
Product ID: \t $productID \n\n
Personal Details: \n
Name: \t $name \n
Email:\t $email \n
Phone:\t $phone \n
Enquiry:\n
$enquiry
";
$headers = "From: $email \n";
$mailSent = mail($recipient, $subject, $body, $headers);
if (!$mailSent) {
header("Location:product_detail.php?id=".$productID."&status=There was an issue sending your enquiry. Sorry");
} else {
header("Location:product_detail.php?id=".$productID."&status=".$model." has been successfully been enquired about");
}
?>
php mail
Moderator: General Moderators
-
maneetpuri
- Forum Commoner
- Posts: 60
- Joined: Tue Oct 07, 2008 6:32 am
Re: php mail
Hi,
The best solution is creating a function for sending email. This function should take three parameter – To, From and Body
Now you can call this function twice both with different parameters and both the mails will be sent but with different body messages.
Hope this help.
Cheers,
The best solution is creating a function for sending email. This function should take three parameter – To, From and Body
Now you can call this function twice both with different parameters and both the mails will be sent but with different body messages.
Hope this help.
Cheers,