- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
这是我的电子邮件表单代码。它运作良好,它发送到我的电子邮件。但是我怎样才能回复从表单收到的电子邮件呢?您能否编辑我的代码并将其放入,因为我是一个大 php 新手。非常感谢!
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$to = "adamgoredesign@gmail.com";
mail ($to, $subject, $message, "From: " . $name);
header('Location: contact_thankyou.html');
?>
最佳答案
你需要设置headers
才能通过sender email:
效果:
<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
所以你的代码看起来像这样:
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$to = "adamgoredesign@gmail.com";
$headers = 'From: '.$email."\r\n" .
'Reply-To: '.$email."\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
header('Location: contact_thankyou.html');
注意:我从未测试过自己,我通常使用 smtp.mail 类为我完成所有这些,因为它更简单、干净... just check it out...
然后它看起来像这样:
<?php
require 'class.phpmailer.php';
$mail = new PHPMailer;
$mail->IsSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup server
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'jswan'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
$mail->From = 'from@example.com';
$mail->FromName = 'Mailer';
$mail->AddAddress('josh@example.net', 'Josh Adams'); // Add a recipient
$mail->AddAddress('ellen@example.com'); // Name is optional
$mail->AddReplyTo('info@example.com', 'Information');
$mail->AddCC('cc@example.com');
$mail->AddBCC('bcc@example.com');
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->Send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
echo 'Message has been sent';
关于php - 回复发件人 - PHP 电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17418751/
我有多个 InOut 模式的顺序队列,每个队列通向一个 Camel 处理器。如果处理器花费太多时间进行处理,我希望请求-答复检测到超时并发送 ExchangeTimedOutException。Cam
我是一名学生,试图了解更多关于 C# 中的 ARP 和套接字的信息 为此,我尝试使用原始 Socket 发送 ARP 请求和回复。在 C# 中。 我已经在一个字节数组中手动重建了一个 ARP 回复
我正在使用 Amazon Web Services 数据库 dynamodb。它返回一个 JSON,看起来像这样: {"Responses":{"friends":[{"to_username":"u
我有 servlet,它创建 html 文件,然后将其转换为 pdf 文件: private void ConvertHTMLtoPDF(String sConvertationProgramm, S
我正在为我的项目使用 Mailkit 库 (Imap)。 我可以轻松地通过 SmtpClient 发送新消息。 目前我正在研究如何回复特定邮件。是否可以向该回复邮件添加更多收件人? @jstedfas
这个问题已经有答案了: How to parse JSON in Java (36 个回答) 已关闭 7 年前。 请您告诉我如何解析 JSON 回复。我从 https://api.privatbank
我正在尝试从事 YouTube 视频评级工作。但我被困在这里了。这两个 YouTube 评级请求有什么区别? https://www.googleapis.com/youtube/v3/videos/
我搜索了该网站,令人惊讶的是没有找到任何适合我情况的答案。所以我发布了这个问题。 我正在使用 jQuery AJAX 来获取网页并将其动态添加到网站。但我的代码不起作用并抛出错误 ERROR Type
我正在编写一个 C 程序来搜索本地网络上的 smb 共享并安装它们。为了获取找到的 smb 服务器的主机名,我向服务器发送了 udp nbns 数据包。数据包正确,服务器回复。我正在使用wiresha
我正在尝试使用 Java 创建自己的 WebSocket 服务器。 当我的客户端连接时,我收到以下请求: (14): GET / HTTP/1.1 (18): Upgrade: WebSocket (
我正在使用 Nodejs、Express、MySQL、EJS。 用户能够创建帖子和评论/回复评论/回复对这些帖子的回复。 问题:我不知道如何以允许我在 EJS 中呈现它们的方式将数据分类为对象/数组。
我正在用 .NET c++ 编写程序。我正在本地网络上发送广播 ping。我的所有目标设备都能够响应 ping 广播,事实上我在 Wireshark 中跟踪了它们的所有响应。我的目标是检索所有响应站点
我有一个向 JMS MDB 发送请求的客户端。它可以很好地向 MDB 发送消息,但我一辈子都无法弄清楚如何让客户端接收 MDB 发回给它的响应。 编辑:客户端代码是同一实例上的 Web 服务,使用 @
我使用钩子(Hook)函数制作了一个模块。它可以工作,但是当我使用 ping google.com 时,我得到 0045 作为 icmp 类型。但我认为它应该是 0 用于回显回复。我使用了以下打印命令
我正在用 C 从头开始编写一个网络库。我已经实现了以太网协议(protocol),现在我想让 ARP 工作。发送请求/回复工作正常,但接收工作不正常。当我发送一个发送请求并等待它之后的回复时,re
我在替换字符串的一部分时遇到问题。现在这段代码。我的目标是针对包含此字典中的键的每个字符串。 mapping = { "St": "Street", "St.": "Stree
我有一个 WCF p2p 网状网络,它运行良好,适合单向对话。我正在研究是否可以调用一种方法来添加两个数字并返回和总和。 但是我在尝试连接时遇到错误: 契约(Contract)需要请求/回复,但绑定(
大家好,我正在尝试使用分块编码流式传输多媒体数据。因此,我首先尝试使用分块编码发送文本数据。 这是我的代码。我创建了一个服务器套接字,我在上面监听请求(端口 80),回复请求,然后我的程序终止。无论您
我的 Servlet 中有一些图像,我想将它们下载到我的 Android 应用中。 我正在对这个 URL 执行一个 GET 请求: public static final String URL ="h
文档:https://developers.google.com/apps-script/reference/gmail/gmail-message#replybody-options 当跟进一封电子
我是一名优秀的程序员,十分优秀!