【问题标题】:php mail() function not working with gmailphp mail()函数不适用于gmail
【发布时间】:2011-09-22 20:30:14
【问题描述】:

PFB 我的代码

<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_port= 587。这些设置也与outlook设置相匹配。

我得到的只是在我的浏览器上打印的“失败”。 请帮忙。

【问题讨论】:

    标签: php


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2011-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-25
      • 2014-03-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多