1

我有这个 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" );

         ?>
4

2 回答 2

0

您只是使用相同的函数以不同的组合重用相同的变量,只是为了将其发送回它们。

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

多田。

要向您和他们发送相同的消息,请使用:

<?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" );

         ?>

要向您和他们发送不同的消息,请使用:

<?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" );
         ?>
于 2012-06-26T23:00:45.697 回答
0

要发送电子邮件:

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';
}
?>
于 2015-10-26T10:13:42.983 回答