无法用PHP发送邮件

时间:2014-04-19 14:34:28

标签: php html forms email

我希望能够通过PHP将用户在文本字段中输入的内容发送到我的电子邮件,但是当我单击“提交”按钮时页面刷新,文本字段清除,并且没有电子邮件发送到我的电子邮件地址。

这是我的PHP:

<?php
$mail = $_POST['mail'];
$formcontent = "Email: $mail";
$recipient = "angrybullet2.webhosting@gmail.com";
$subject = "Mail that uploaded picture";
$mailheader = "From: my website";

mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo 'OK ! Your mail address has been successfully added to your photo !<br>We will contact you later :)';
?>

这是我的HTML:

<html>
<body bgcolor="lightpink">
  <div align="center">
    <font face="helvetica" size="5px" color="#009933">
      Your photos has been successfully uploaded !<br>Enter your email address to tell you how to win the $50 000 !
    </font>
    <form name="form" id="login" method="POST" action="up_ok_send_mail.php">
      <input type="text" name="mail" id="mail" size="70" placeholder="Enter your email address here">
      <input type="submit" name="submit" id="submit" value="submit">
    </form>
</body>
  </div>
</html>

我不知道发生了什么。我尝试使用此PHP将此HTML托管在除我网站其余部分之外的目录中(包括Mohan suggested me to addprint_r函数。一切都很棒,但是当这个HTML链接到必须在它之前的页面时,整个过程都不​​起作用。提交电子邮件时,页面会刷新,并且不会向我的电子邮件地址发送电子邮件。


好。有效。我设法通过将电子邮件提交字段放在链接到的同一HTML文件中来解决我的问题。我的意思是没有更多链接到这个页面。现在一切都在同一个HTML上。

1 个答案:

答案 0 :(得分:0)

表单未提交或者如果您在localhost中工作,您将无法通过smtp协议发送邮件,检查表单是否正在提交至up_ok_send_mail.php页面

相关问题