首页 \ 问答 \ 使用php [重复]从html表单发送电子邮件(Sending email from html form using php [duplicate])

使用php [重复]从html表单发送电子邮件(Sending email from html form using php [duplicate])

这个问题在这里已有答案:

我一整天都在尝试这个,但我无法弄清楚如何从我的html联系表单发送一封电子邮件,其中包含表格中的信息到我的电子邮件地址。 我是php新手。

我已经尝试通过将其上传到免费的虚拟主机来运行它。 我得到的消息是“成功!” 当我按下html表单上的提交按钮但实际上没有发送电子邮件时。

任何帮助表示赞赏。

PHP脚本:

<?php

//Subject
$subject ="Contact Form Submission";

// Name
$name =$_POST['InputName'];

// Message
$message =$_POST['InputMessage'];

//Mail of Sender
$email =$_POST['InputEmail'];

//From
$header = "From:$name<$email>";

$send_contact=mail("myemail@gmail.com",$subject,$message,$header);

//Check if mail was sent
if($send_contact){
echo "Success!";
}
else {
echo "Error!";
}
?>

编辑:经过一整天的反复试验后想出来。 问题在于我使用的免费网络主机。 更改了主机,代码开始正常工作。 希望这可以帮助将来的某个人。 谢谢大家的帮助。


This question already has an answer here:

Ive been trying this out the whole day but I cant figure out how to send an email from my html contact form containing the information from the form to my email address. Im new to php.

Ive tried running this by uploading it to free web hosting. I get the message "success!" when I press the submit button on my html form but no email is actually sent.

Any help is appreciated.

PHP script:

<?php

//Subject
$subject ="Contact Form Submission";

// Name
$name =$_POST['InputName'];

// Message
$message =$_POST['InputMessage'];

//Mail of Sender
$email =$_POST['InputEmail'];

//From
$header = "From:$name<$email>";

$send_contact=mail("myemail@gmail.com",$subject,$message,$header);

//Check if mail was sent
if($send_contact){
echo "Success!";
}
else {
echo "Error!";
}
?>

EDIT: Figured it out after one whole day of trial and error. The problem was with the free web host I was using. Changed hosts and the code started working fine. Hope this helps someone in the future. Thanks all for the help.


原文:https://stackoverflow.com/questions/39062332
更新时间:2023-06-11 11:06

最满意答案

Kafka Connect可以处理流数据,并且更灵活一些。 如果您只是弹性,Filebeat是一个干净的日志源集成。 但是,如果您从Kafka到许多不同的水槽,Kafka Connect可能就是您想要的。 我建议您查看连接器集线器以查看当前可供您使用的开源连接器的一些示例http://www.confluent.io/product/connectors/


Kafka Connect can handle streaming data and is a bit more flexible. If you are just going to elastic, Filebeat is a clean integration for log sources. However, if you are going from Kafka to a number of different sinks, Kafka Connect is probably what you want. I'd recommend checking out the connector hub to see some examples of open source connectors at your disposal currently http://www.confluent.io/product/connectors/

相关问答

更多
  • 将设置添加到filebeat.yml 您可以在路径中看到输出日志作为文件,以查看发生的情况。 output.file: # Boolean flag to enable or disable the output module. enabled: true # Path to the directory where to save the generated files. The option is # mandatory. path: "your path" # Name of the generat ...
  • 您的filebeat.yml看起来无效。 输出部分缺少缩进: output.logstash: hosts: ["10.10.XX.XX:5044"] 通常,检查配置文件的正确性以确保它们没问题。 例如,对于filebeat,您可以运行: filebeat -c /etc/filebeat/filebeat.yml -configtest 如果您有任何错误,它会解释该错误是什么,以便您可以解决它。 您也可以对其他ELK服务使用类似的方法 Your filebeat.yml looks invalid ...
  • Kafka Connect可以处理流数据,并且更灵活一些。 如果您只是弹性,Filebeat是一个干净的日志源集成。 但是,如果您从Kafka到许多不同的水槽,Kafka Connect可能就是您想要的。 我建议您查看连接器集线器以查看当前可供您使用的开源连接器的一些示例http://www.confluent.io/product/connectors/ Kafka Connect can handle streaming data and is a bit more flexible. If you a ...
  • 我们的想法是在每个收集日志和统计信息所需的服务器上安装Filebeat。 每个Filebeat实例都会尽可能快地抓取和发送日志,而无需对可以进行大量处理和过滤的集中式Logstash实例进行任何处理。 以前,Logstash有一个轻量级的logstash-forwarder模块,它可以执行与Filebeat大致相同的工作。 Filebeat是集中来自所有不同主机的日志的新官方和标准方法。 The idea is to install Filebeat on every server you need to ...
  • 我可以看到本主题中提到的两个问题。 让我为自己的利益进行总结,并希望其他参与者也在为这个问题而努力。 格式在filebeat探矿器中添加标签(每个探矿者标签自5.0或1.2.3开始可用) 坏: fields: tags: mytag 好: fields: tags: ["mytag"] 但是,还有更重要的问题 标签被连接起来。 我们希望标签是一个数组,但是如果我们将新添加的标签发送到logstash,我们会在ES中看到它们是串联的字符串。 如果您只添加一个标签,则解决方法 ...
  • 你走在一条好路上。 请确认以下内容: 在你的filebeat.yml文件中,确保你没有在output.logstash:行中有注释,这与你的更改编号2相对应。 确保你的信息正确无误。 在logstash管道配置文件中添加以下输出。 输出{stdout {codec => json}} 3.在调试模式下启动logstash。 4.如果您正在阅读具有相同内容的相同文件,请确保在filebeat中删除注册表文件。 ($ filebeatHome /数据/注册表) 5.阅读日志文件。 You are in a go ...
  • 当您将Beats与Logstash结合使用时,您会遇到一种称为“背压管理”的东西 - 例如,如果网络出现问题,Beats将停止使用消息充斥Logstash服务器。 使用Beats的另一个好处是,在Logstash中,您可以拥有持久队列,这可以防止您在弹性搜索群集出现故障时丢失日志消息。 因此Logstash会将消息保留在磁盘上。 请注意,因为如果您使用UDP,Logstash无法确保您不会丢失消息, 此链接将非常有用。 When you couple Beats with Logstash you have ...
  • 您需要使用grok过滤器解析message然后才能应用JSON过滤器 。 如果您可以修改应用程序的记录器配置以输出纯JSON,那么就更好了,因此根本不需要grok解析。 filter { # Parse the log message. grok { pattern_definitions => { "LOGDATE" => "[\d]{4}-[\d]{2}-[\d]{2} %{TIME}" "LOGHEADER" => "%{LOGDATE:logdate} % ...
  • 不,使用beats协议的文件输出不适用于tcp输入。 您可以选择如何解决此问题。 升级Logstash:在我推荐任何黑客或使用已弃用的软件之前,最好的选择只是将logstash升级到现代版本,几乎没有重大变化和大量性能升级。 手动将节拍输入添加到Logstash:您可以使用/opt/logstash/bin/logstash-plugin install logstash-input-beats将节拍输入添加到logstash 2.x 使用logstash-forwarder:不推荐使用Filebeats的 ...
  • Beats和Logstash之间的连接不基于HTTP协议,因此不要使用URL配置hosts选项。 每个Logstash主机的格式应为host:port 。 正如您从错误消息中看到的那样,它正在尝试解析您指定为域名的完整值,这是错误的(即它与nslookup "http://localhost:5044/"相当)。 问题中显示的配置中的缩进也是关闭的。 hosts设置应该是logstash的子项,因此需要缩进。 尝试使用它来避免任何缩进问题: output.logstash.hosts: ['logstash ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)