Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

i have one contact form, when user submit all value will send(email) to admin.But now i want to do when user submit admin will receive the email and user also will receive an email but with different body.

here my previous code :

<?php
if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){

$name= $_POST["name"];
$email= $_POST["email"];
$phone= $_POST["phone"];
$company= $_POST["company"];
$message= $_POST["message"];

require_once('lib/class.phpmailer.php');

$mail             = new PHPMailer(); // defaults to using php "mail()"

$mail->AddReplyTo("admin@gmail.com","I Concept");

$mail->SetFrom('admin@gmail.com', 'I Concept');

$mail->AddReplyTo("admin@gmail.com","I Concept");

$address = "admin@gmail.com";
$mail->AddAddress($address, "I Concept");

$mail->Subject    = "MY - Request a Quote";

$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->Body = "<strong>Request a Quote from I Concept Malaysia Website</strong><br><br> 

Name : $name<br>
Email : $email<br> 
Phone : $phone<br> 
Company : $company<br> 
Enquiry : $message<br> <br> 

Thank You!<br>

";

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!<br>";
}


}
?>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
507 views
Welcome To Ask or Share your Answers For Others

1 Answer

Try the following. Didn't test but you basically need to get another PHPMailer object going and set the body and to information separately.

$address = "admin@gmail.com";
$mail->Subject    = "MY - Request a Quote";

// keeps the current $mail settings and creates new object
$mail2 = clone $mail;

// mail to admin
$mail->AddAddress($address, "I Concept");
$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->Body = "<strong>Request a Quote from I Concept Malaysia Website</strong><br><br> 

    Name : $name<br>
    Email : $email<br> 
    Phone : $phone<br> 
    Company : $company<br> 
    Enquiry : $message<br> <br> 

    Thank You!<br>";

if(!$mail->Send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!<br>";
}

// now send to user.
$mail2->AddAddress($email, $name);
$mail2->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail2->Body = "Separate email body for user filling form out.";

if(!$mail2->Send()) {
    echo "Mailer Error: " . $mail2->ErrorInfo;
} else {
    echo "Message sent!<br>";
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...