提交表单后发送两封不同的电子邮件 [英] Send two different emails after form submission

查看:106
本文介绍了提交表单后发送两封不同的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户提交表单时,我希望一封电子邮件与表单字段一起发送给我,并希望向用户发送一封单独​​的电子邮件以确认他们的提交(两封内容不同的电子邮件)。

When a user submits a form, I want one email to come to me with the form fields and a separate email to be sent to the user confirming their submission (two separate emails with different content).

我尝试了以下形式,但仅生成第一封电子邮件。永远不会收到第二封电子邮件。

I tried the following form, but only the first email is generated. The second email is never received.

<?php
$url = "http://www.example.com";

$to = 'info@example.com';
$subject = 'Subject';
$headers .= "From: info@example.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message .= "Content of Message 1";
mail($to, $subject, $message, $headers);

$message = ""; 

$to = $_POST['email'];
$subject = 'Subject';
$headers .= "From: info@example.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message .= "Content of Message 2";
mail($to, $subject, $message, $headers);

$message = "";

echo '<META HTTP-EQUIV=Refresh CONTENT="1; URL='.$url.'">';

?>

什么会阻止第二条消息的发送?

What would prevent the second message from sending?

推荐答案

更改变量名,同时 $ to $ subject 被第二封电子邮件的连接变量覆盖。.保持连接成双重混乱。

Change the variable names,while $to and $subject are overwritten for the second email the concatenating variables..keep concatenating into a double mess.

这篇关于提交表单后发送两封不同的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆