Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将gmail发送到admin';来自本地主机的gmail_Php - Fatal编程技术网

Php 将gmail发送到admin';来自本地主机的gmail

Php 将gmail发送到admin';来自本地主机的gmail,php,Php,我想将邮件从localhost发送到我的gmail帐户。我在php.ini和sendmail.ini中设置了使用smtp服务器的所有设置。当我发送数据时,一切正常,但我没有收到任何传入消息。我怎么做?请帮助我 这是我的代码mail.php <form method="post" action="sendmail.php"> Email address: <input name="email" type="text" /> <br />

我想将邮件从localhost发送到我的gmail帐户。我在php.ini和sendmail.ini中设置了使用smtp服务器的所有设置。当我发送数据时,一切正常,但我没有收到任何传入消息。我怎么做?请帮助我

这是我的代码mail.php

<form method="post" action="sendmail.php">
    Email address:
    <input name="email" type="text" />
    <br /> Name:
    <input name="name" type="text" />
    <br /> Message:
    <br />
    <textarea name="message" rows="15" cols="40"></textarea>
    <br />
    <input type="submit" />
</form>
<?php
    echo 'Current PHP version: ' . phpversion();
    $email_to = "khinthidaphyo92@gmail.com";
    $name = $_POST["name"];
    $email_from = $_POST["email"];
    $message = $_POST["message"];
    $email_subject = "Feedback from website";
    $headers = "From: " . $email_from . "\n";
    $headers .= "Reply-To: " . $email_from . "\n";
    $message = "Name: ". $name . "\r\nMessage: " . $message;
    ini_set("sendmail_from", $email_from);
    $sent = mail($email_to, $email_subject, $message, $headers, "-f" .$email_from);
    echo $sent;
    echo "sent mail is" .$sent;
    if ($sent)
    {
        echo "It has been sent";
    } else {
        echo "There has been an error sending your comments. Please try later.";
    }
?>

电邮地址:

名称:
消息:

这里是sendmail.php

<form method="post" action="sendmail.php">
    Email address:
    <input name="email" type="text" />
    <br /> Name:
    <input name="name" type="text" />
    <br /> Message:
    <br />
    <textarea name="message" rows="15" cols="40"></textarea>
    <br />
    <input type="submit" />
</form>
<?php
    echo 'Current PHP version: ' . phpversion();
    $email_to = "khinthidaphyo92@gmail.com";
    $name = $_POST["name"];
    $email_from = $_POST["email"];
    $message = $_POST["message"];
    $email_subject = "Feedback from website";
    $headers = "From: " . $email_from . "\n";
    $headers .= "Reply-To: " . $email_from . "\n";
    $message = "Name: ". $name . "\r\nMessage: " . $message;
    ini_set("sendmail_from", $email_from);
    $sent = mail($email_to, $email_subject, $message, $headers, "-f" .$email_from);
    echo $sent;
    echo "sent mail is" .$sent;
    if ($sent)
    {
        echo "It has been sent";
    } else {
        echo "There has been an error sending your comments. Please try later.";
    }
?>


您的系统是什么?窗户?用于windows

如果您使用本地主机直接发送电子邮件,则邮件可能最终会进入谷歌的垃圾邮件过滤器。最简单的选择是只使用本地邮件器将电子邮件转发到gmail服务器,然后由gmail服务器进行实际的邮件发送。这样谷歌不会认为你是一个垃圾邮件发送者。 在如何将Gmail配置为Sendmail电子邮件中继中有一篇关于这一点的文章


更简单的方法是使用internet服务提供商的smtp服务器,该服务器在从其网络连接时通常甚至不需要身份验证。

您在localhost中使用的是哪台服务器来发送邮件?