简体   繁体   English

确认邮件

[英]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. 我已经有了这个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", "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';
}
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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