为什么我的PHP脚本不发送电子邮件? [英] Why is my php script is not sending email?

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

问题描述

我正在尝试向我的电子邮件地址'iamhamzach@gmail.com'发送反馈消息,脚本正常运行,但我没有收到电子邮件。请告诉我是什么问题。



html:

  < HTML> 
< body>
< form action =email.phpmethod =post>
< input type =textid =namevalue =namename =name/>< br>
< input type =submitvalue =submit/>
< / form>
< / body>
< / html>

php:

 <?php 


$ emailSubject ='我的第一封邮件';
$ webMaster ='iamhamzach@gmail.com';

$ emailField = $ _POST ['email'];
$ nameField = $ _POST ['name'];
$ commentField = $ _POST ['comment'];

$ body =<<< EOD
< br>< hr>< br>
电子邮件地址:$ email< br>
名称:$ name< br>
评论:$ comment< br>
EOD;

$ headers =From:$ email\r\\\
;
$ headers。=Content-type:text / html\r\\\
;
$ success = mail($ webMaster,$ emailSubject,$ body,$ headers);

$ theResults =<<< EOD
< html>
< body>
感谢您的回馈
< / body>
< / html>
EOD;
回显$ theResults;

?>


解决方案

大多数localhosts不支持开箱即用的电子邮件。

尝试将此脚本上传到您的虚拟主机,它应该没问题。



代码看起来不错。


i am trying to send a feedback message to my email address 'iamhamzach@gmail.com', the scripts are running properly and but i have not receiving email. please tell me what is the problem..

html:

<html>
  <body>
    <form action="email.php" method="post">
      <input type="text" id="name" value="name" name="name"/><br>
      <input type="text" id="email" value="email" name="email"/><br>
      <input type="text" id="comment" value="comment" name="comment"/><br>
      <input type="submit" value="submit"/>
    </form>
  </body>
</html>

php:

<?php


    $emailSubject = 'my first mail';
    $webMaster = 'iamhamzach@gmail.com';

    $emailField = $_POST['email'];
    $nameField = $_POST['name'];
    $commentField = $_POST['comment'];

    $body = <<<EOD
    <br><hr><br>
    Email: $email <br>
    Name: $name <br>
    Comments: $comment <br>
    EOD;

    $headers = "From: $email\r\n";
    $headers .= "Content-type: text/html\r\n";
    $success = mail($webMaster, $emailSubject, $body, $headers);

    $theResults = <<<EOD
      <html>
        <body>
          Thank you for your feed back
        </body>
      </html>
    EOD;
    echo "$theResults";

?>

解决方案

most localhosts dont support emailing out of the box.

try to upload this script to your webhost and it should be fine.

the code looks ok.

这篇关于为什么我的PHP脚本不发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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