【发布时间】:2022-07-07 23:17:17
【问题描述】:
大家好,我正在使用 xampp 使用 mail() 发送邮件,但我认为我需要关闭不太安全的应用程序,但由于谷歌删除了它,任何人都知道让代码运行的任何替代方法。
<?php
$receiver = "2020@gmail.com";
$subject = "Email Verification Code";
$message = "Your verification code is ";
$sender = "From: NatsuDragneelxd42069@gmail.com";
if(mail($receiver, $subject, $message, $sender))
{
echo "Email sent successfully to $receiver";
}
else
{
echo "Sorry, failed while sending mail!";
}
?>
修改了php.ini和sendmail.ini
SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = my-gmail-id@gmail.com
sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=my-gmail-id@gmail.com
auth_password=my-gmail-password
force_sender=my-gmail-id@gmail.com
如果您知道安全性较低的应用程序的替代方案,或者您发现代码中有错误,请发表评论。
【问题讨论】: