本文介绍了使用php从html表单发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一整天都在尝试,但是我不知道如何从我的html联系表单中发送一封电子邮件,其中包含表单中的信息到我的电子邮件地址。新到php
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尝试通过将其上传到免费的网页托管运行。我得到了消息成功!当我按下我的HTML表单上的提交按钮,但没有发送电子邮件。
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.
任何帮助都不胜感激。
PHP脚本:
c $ c添加到刚刚创建的电子邮件地址。
- When you pass "from" in headers, php expects an existing email account of your
server. For example : $headers = 'From: [email protected]'; - So first thing you gotta do is create an email account on your server. And then put the From in header to the email address that you've just created.
- The From field in the $headers is not the From as you think.
- <?php
- $email = $_POST["InputEmail"];
- $subject = $_POST["InputSubject"];
- $message = "From: ".$email.", ".$_POST["InputMessage"]; // you put the email address from the input form here
- $headers = 'From: [email protected]'; // here is the email address specified from which u want to send the email.(i.e. your server email address)
- mail($to, $subject, $message, $headers)
- ?>
我相信这会做这个工作:)
I'm sure this will do the job :)
这篇关于使用php从html表单发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!