表格发送电子邮件不工作。代码有什么问题吗? [英] Form to send Email not working. Is there anything wrong in the code ?

查看:98
本文介绍了表格发送电子邮件不工作。代码有什么问题吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

发送电子邮件无效的表单。代码有什么问题吗?



index.html



Form to send Email not working. Is there anything wrong in the code ?

index.html

<html>
<body>

<div id = "container">
<form method  = "post" action = "process.php">

<b><h4>To (Enter an Email address)</h4></b><input type = "email" id = "to" name = "to">

<h4>Enter subject</h4> <textarea name = "subject" rows = "1" cols = "80" > </textarea>

<h4>Enter the message</h4> <textarea name = "message" rows = "17" cols = "100" > </textarea>

<center><input type = "submit" label = "Send"></center>

</form>
</div>

</body>
</html>







process.php






process.php

<?php

$to = $_POST['$to'];
$subject = $_POST['subject'];
$message = $_POST['$message'];

mail($to, $subject, $message);
echo "Your Email has been sent successfully to" ." ". $to  ;

?>





我' m使用postfix SMTP服务器在localhost上使用LAMP。我也尝试过托管服务。它也不在那里工作。电子邮件不会发生。代码中有什么问题吗?



如果我犯了任何愚蠢的错误,请原谅。我通过阅读没有老师指导的书来自学编码。



I'm using LAMP on localhost with postfix SMTP server. I also tried it on a hosting service. Its not working there also. Emails are not going. Anything wrong in the code ?

Pardon if I have done any silly mistake. I learn coding on my own by reading books with no teacher to guide.

推荐答案

到 =
to =


_POST ['
_POST['


to'];
to'];


这篇关于表格发送电子邮件不工作。代码有什么问题吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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