0

我正在使用电子邮件激活系统。系统回显,电子邮件已发送,邮件功能正常工作,但我无法收到任何电子邮件

我在 php.ini 中进行了某些配置

;SMTP = smtp.gmail.com
sendmail_from = horsepowerbank@gmail.com
auth_username=horsepowerbankgmail.com
auth_password=XXXXXX
sendmail_path ="\"C:\wamp\sendmail\sendmail.exe\" -t"

我通过这个 php 文件测试功能

发送邮件.php

<?php
$to       = 'mineble2014@gmail.com';
$subject  = 'Testing sendmail.exe';
$message  = 'Hi, you just received an email using sendmail!';
$headers  = 'From: horsepowerbank@gmail.com' . "\r\n" .
            'Reply-To: horsepowerbank@gmail.com' . "\r\n" .
            'MIME-Version: 1.0' . "\r\n" .
            'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
            'X-Mailer: PHP/' . phpversion();
if(mail($to, $subject, $message, $headers))
    echo "Email sent";
else
    echo "Email sending failed";
?>

mail() 功能运行良好,它回显“电子邮件发送”..但我检查了 mineble2014@gmail.com,我在收件箱、垃圾邮件等中看不到任何电子邮件...

而且我还想将激活电子邮件发送给用户,让他们激活他们的帐户,代码运行成功,但没有收到任何电子邮件..这是我在 register.php 的代码

注册.php

<?php

        //create random number
        $code = rand("11111111,99999999");

        //declare variable to send the email activation
        $to = $email;
        $subject = "Activate your account";
        $header = "From watevershit.com non-reply";
        $body ="Hello,$username please activate your account by clink the link below or paste it in url bar in your browse \n\n http://watevershit/activate.php?code=$code";

        //HASHING THE PASSWORD
        $password = md5($password);

        $queryinsert= "INSERT INTO user(Username,Password,Email) VALUES ('$username','$password','$email')";
        mysqli_query($con,$queryinsert);

        if(!mail($to,$subject,$header,$body)){
            echo "We are sorry,we cant registered you at this moment";
        }else{
            echo" You are registered successfully,please check your email ($email) to activate your account.Thank you";
        }

        header("Location:login.php");

?>

我在上面设置的 $code 不会生成任何东西,而数据库中只有 0 ..所以伙计们,对此有什么想法吗?

4

0 回答 0