首页 > 解决方案 > 当我从 SMTP 发送电子邮件时,它的代码成功运行,但我没有在该电子邮件地址上收到电子邮件?

问题描述

我已经更改了 gmail 的安全性,因为不太安全允许并启用 IMAP...还在 sendmail.exe 和 php.ini 中进行一些更改.....

在 sendmail.exe 中......

smtp_server=smtp.gmail.com 
smtp_port=465 
smtp_ssl=ssl
default_domain=localhost 
error_logfile=error.log
debug_logfile=debug.log
auth_username=email address from where i send mail
auth_password= my password 
hostname=localhost

在 php.ini...

sendmail_path =  "C:\wamp64\sendmail\sendmail.exe  -t  -i"

我的PHP代码...

<?php
$mail=$_REQUEST['mail'];

$otp=rand(100000,999999);
            $to=$mail;
            $subject= "OTP From Skin Beauty Bar";
            $message="hiii...\n Your OTP Is = ".$otp."\n Please Don't Share Yor One Time password";
            $headers= "FROM:skinbeautyproducts94@gmail.com";

            if(mail($to, $subject, $message, $headers))
            {
                echo "<script>alert('OTP SENT');window.location.href='otp_pg.php?mail=$mail&msg=$otp';</script>";
            }
            else{
                echo "xyz";
            }
?>

标签: phpemail

解决方案


推荐阅读