2012-06-26 226 views
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("[email protected]", "Axsiom: Contact Us", $body, "From: $email"); 

     ?> 
+0

什麼是淨化'$ _REQUEST'變量在這裏?這是你創建的一個數組還是所有這些數據都是由用戶直接提供的? – sarnold

+0

嗯,如果你可以發送郵件到'info @ axsiom.com.au'爲什麼你不能發送一個''email'就像'mail($ email,「Thanks」,$ msg,「noreply @ axsiom」 )' –

回答

0

您只是在不同的組合中重複使用相同的變量,使用相同的功能只是將它們發回給它們。

mail($email, "Thank You", "We Have Recived Your Request blablabla", "From: [email protected]"); 

Tada。

發送相同的消息,你和他們使用:

<?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("[email protected], $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("[email protected]", "Axsiom: Contact Us", $body, "From: $email"); 
    //to them 
    mail($email, "Thank You", "We Have Recived Your Request blablabla", "From: [email protected]"); 
     ?> 
+0

因此,如果我添加郵件(「[email protected]」,「Axsiom:聯繫我們」,$ email,$ body,「From:$ email」);是否會將信息發送給我和用戶? –

+0

@MichaelPetridis請參閱編輯。這是否清除它? –

+0

非常感謝,非常感謝,瞭解它現在如何工作:) –

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 = '[email protected]';     // 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 = '[email protected]'; // 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'; 
} 
?>