如何将php邮件发送给管理员并向订阅者回复感谢信息?

时间:2015-03-27 06:52:27

标签: php phpmailer

我有以下PHP代码发送邮件,它工作正常。它的联系表格,信息发送给管理员并回复订阅者的感谢信息。

$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$sub=$_POST['subject'];
$describe=$_POST['describe'];
$mail -> From = "karthik@xfacttechnologies.com";
$mail -> FromName = "Vignesh Agency";
$mail -> AddAddress ("karthik@xfacttechnologies.com");
$mail -> headers = "From: vigneshagency\r\n";
$mail -> headers .= "Reply-To: ". strip_tags($_POST['email']) . "\r\n";
$mail -> headers .= "MIME-Version: 1.0\r\n";
$mail -> headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$mail -> Subject = "Vignesh Agency";
$mail -> IsHTML (true);
$mail -> Body .= '<html><body>';
$mail -> Body .='<table style="width:60%;border:1px solid #eee;"      border="1" bordercolor="#eee" cellpadding="6" cellspacing="0">';
$mail -> Body .='<tr><th colspan="2" style="background-color:#7DA3B3;    color: white;"><h2>Customer Details</h2></th></tr>';
$mail -> Body .="<tr><td><b>Name </b></td><td>".$name."</td></tr>";
$mail -> Body .="<tr><td><b>E-mail </b></td><td>".$email."</td></tr>";
$mail -> Body .="<tr><td><b>Phone</b></td><td>".$phone."</td></tr>";
$mail -> Body .="<tr><td><b>Purpose </b></td><td>".$sub."</td></tr>";
$mail -> Body .="<tr><td><b>Message </b></td><td>".$describe."</td></tr> </table>";
$mail -> Body .= "</body></html>";


if(!$mail->Send()) 
echo "Error:" . $mail->ErrorInfo;
else 
echo "<script>window.location = 'http://vigneshagency.com/contact.html'</script>";
exit();

只需向订阅者发送回复邮件,例如“感谢您访问我们”

1 个答案:

答案 0 :(得分:0)

最后我找到了解决方案。如何将自动邮件发送到订阅者

$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$sub=$_POST['subject'];
$describe=$_POST['describe'];
$mail -> From = "******@gmail.com";
$mail -> FromName = "abvdAgency";
$mail -> AddAddress ("******@gmail.com");
$mail -> headers = "From: abcd agency\r\n";
$mail -> headers .= "Reply-To: ". strip_tags($_POST['email']) . "\r\n";
$mail -> headers .= "MIME-Version: 1.0\r\n";
$mail -> headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$mail -> Subject = "abcd Agency";
$mail -> IsHTML (true);
$mail -> Body .= '<html><body>';
$mail -> Body .='<table style="width:60%;border:1px solid #eee;"      border="1" bordercolor="#eee" cellpadding="6" cellspacing="0">';
$mail -> Body .='<tr><th colspan="2" style="background-color:#7DA3B3;    color: white;"><h2>Customer Details</h2></th></tr>';
$mail -> Body .="<tr><td><b>Name </b></td><td>".$name."</td></tr>";
$mail -> Body .="<tr><td><b>E-mail </b></td><td>".$email."</td></tr>";
$mail -> Body .="<tr><td><b>Phone</b></td><td>".$phone."</td></tr>";
$mail -> Body .="<tr><td><b>Purpose </b></td><td>".$sub."</td></tr>";
$mail -> Body .="<tr><td><b>Message </b></td><td>".$describe."</td></tr> </table>";
$mail -> Body .= "</body></html>";


if(!$mail->Send()) 
{
echo "Error:" . $mail->ErrorInfo;
}
else 
{
// To send automated reply mail
$autoemail = new PHPMailer(); 
$autoemail->From = "*****@gmail.com"; 
$autoemail->FromName = "ABCD Agency"; 
$autoemail->AddAddress($email, $mail->FromName); 
$autoemail->Subject = "Autorepsonse: We received your submission"; 
$autoemail->Body = "We received your submission. We will contact you soon ...";
$autoemail->Send(); 
echo "<script>window.location = 'http://vigneshagency.com/contact.html'</script>";
exit();
}