简体   繁体   中英

confirmation email

I've got this php code to send the users information from the contact form to my email address, but i don't know how to send a confirmation email back to the user when he fills out the form.

<?      
 $name = $_REQUEST['name'] ; 

 $company = $_REQUEST['company'] ;

 $areacode_telephone = $_REQUEST['areacode_telephone'] ;

 $telephone = $_REQUEST['telephone'] ;

 $email = $_REQUEST['email'] ;

 $notes = $_REQUEST['notes'] ;

 $body =        " Name: ".$name."\n

                 Company: ".$company."\n

                 Area Code: ".$areacode_telephone."\n 

                 Telephone: ".$telephone."\n 

                 Email Address: ".$email."\n

                 Notes: ".$notes;

     mail( "info@axsiom.com.au", "Axsiom: Contact Us", $body, "From: $email" );

         ?>

You are just reusing the same variables in a different combination using the same function just to send it back to them.

mail( $email, "Thank You", "We Have Recived Your Request blablabla", "From: info@axsiom.com.au" );

Tada.

To send the same message to both you and them use:

<?php      
 $name = $_REQUEST['name'] ; 

 $company = $_REQUEST['company'] ;

 $areacode_telephone = $_REQUEST['areacode_telephone'] ;

 $telephone = $_REQUEST['telephone'] ;

 $email = $_REQUEST['email'] ;

 $notes = $_REQUEST['notes'] ;

 $body =        " Name: ".$name."\n

                 Company: ".$company."\n

                 Area Code: ".$areacode_telephone."\n 

                 Telephone: ".$telephone."\n 

                 Email Address: ".$email."\n

                 Notes: ".$notes;

     mail( "info@axsiom.com.au, $email", "Axsiom: Contact Us", $body, "From: $email" );

         ?>

To send a different message to both you and them use:

<?php      
 $name = $_REQUEST['name'] ; 

 $company = $_REQUEST['company'] ;

 $areacode_telephone = $_REQUEST['areacode_telephone'] ;

 $telephone = $_REQUEST['telephone'] ;

 $email = $_REQUEST['email'] ;

 $notes = $_REQUEST['notes'] ;

 $body =        " Name: ".$name."\n

                 Company: ".$company."\n

                 Area Code: ".$areacode_telephone."\n 

                 Telephone: ".$telephone."\n 

                 Email Address: ".$email."\n

                 Notes: ".$notes;

     //to you
     mail( "info@axsiom.com.au", "Axsiom: Contact Us", $body, "From: $email" );
     //to them
     mail( $email, "Thank You", "We Have Recived Your Request blablabla", "From: info@axsiom.com.au" );
         ?>

To send email:

require 'PHPMailerAutoload.php';

$mail = new PHPMailer;


$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'user@gmail.com';                 // Your gmail username
$mail->Password = 'your_gmail_password';                           // SMTP password
$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;                                    // TCP port to connect to

$mail->From = 'from@example.com'; // from email address
$mail->FromName = 'User1'; // whatever is the name of sender
$mail->addAddress($_POST['email'], $_POST['username']);     // Add a recipient

$mail->isHTML(true);                                  // Set email format to HTML

$mail->Subject = $subject;
$mail->Body    =  $message ;

if(!$mail->send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent';
}
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM