我有这个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" );
?>
答案 0 :(得分: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" );
?>
答案 1 :(得分: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';
}
?>