php mail()函数不适用于gmail

php mail()函数不适用于gmail,php,Php,我的代码 <html> <head> <title> Your information</title> </head> <body> <?php $x = $_POST['yourname']; $email = $_POST['email']; $msg="Your Name is $x."; $to='abc@gmail.com'

我的代码

<html>
    <head>
        <title> Your information</title>
    </head>
    <body>
    <?php

    $x = $_POST['yourname'];


    $email = $_POST['email'];
    $msg="Your Name is $x.";
    $to='abc@gmail.com';
    $sub='Your information';
    $header = "From: ". $x . " <" . $email . ">\r\n";
    ini_set("SMTP","smtp.gmail.com" );
    ini_set('sendmail_from', 'abc@gmail.com');
    //$email is entered as abc@gmail.com
    if(mail($to, $sub, $msg,'From:' . $email)){
        echo 'success';
    }
    else{
        echo 'failure';
    }


echo 'Thanks for submitting your information<br/>';
echo 'Your Name ' . $x . '<br/>' ;
echo 'Email ' . $email . '<br/>' ;
echo $msg;
?>
    </body>
</html>

你的信息
我已经用我的gmail帐户(POP/SMTP)配置了outlook 2007。 php.ini设置为SMTP=SMTP.gmail.com smtp_端口=587。这些设置也与outlook设置相匹配

但我得到的只是浏览器上的“失败”。 请帮助。

您需要使用“ssl”从Gmail发送电子邮件。您可以下载PhPmailer并查看他们为gmail提供的示例。

您需要使用“ssl”从gmail发送电子邮件。您可以下载PhPmailer,并可以看到他们为gmail提供的示例