Page 1 of 1

How to send 2 different messages from 1 form.

Posted: Sun Apr 11, 2010 2:13 pm
by smartguy1616

Code: Select all

<?php
$your_name = $_POST['your_name'];
$friend_name = $_POST['friend_name'];
$your_email = $_POST['your_email'];
$friend_email = $_POST['friend_email'];
$personal_message = $_POST['personal_message'];

$to =  $friend_email;
$subject = 'Your Friend ' . $your_name . 'sends you an e-mail';
$msg = "Hello Mr. XYZ\n" .

"This is the message 1 - $personal_message";
mail($to, $subject, $msg, 'From:' . $your_email);

$to1 =  'abc@yahoo.com';
$subject1 = 'I guess there is one more E-Advocate';
$msg1 = "Hi Mr. ABC, This is message 2-\n" .
"Name - $your_name\n" .
"E-Mail - $your_email\n" .
"The Reciever's/Recievers' Name/Names - $friend_name\n" .
"The Reciever's/Recievers' E-Mail/E-Mails - $friend_email\n" .
"\n";
mail($to1 , $subject1, $msg1, 'From:' . $your_email);

echo '<h2>Thank You ' . $your_name . '. Your Message has Been Sent.</h2><br />';
echo 'We conveyed your friend/friends -' . $friend_name . ' about our mission and that you are supporting it. <br />';
echo 'We also told him/her/them that - &quot' . $personal_message . '&quot <br 1/>';
echo 'Thanks a lot from The Akshaya Patra Foundation <br />';
?> 
Using the above code I am trying to send 2 different messages to 2 different recepients using the data from the same html form. I dont know why it is not working. I tried a lot to find in the internet but could not. I do not know whether this is the correct method. I thought naming the variable differently under the mail() function of php would help me in sending 2 different e-mails. Please help me out with this. :banghead:

Re: How to send 2 different messages from 1 form.

Posted: Sun Apr 11, 2010 5:22 pm
by yacahuma