我正在研究电子邮件激活系统。系统回显,发送电子邮件,邮件功能正常,但我无法接收任何电子邮件
我在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文件测试函数
发送-mail.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
register.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 ..那么伙计们,对此有什么看法?