【问题标题】:is there an alternative way of turning on less secure app from gmail?是否有另一种方法可以从 gmail 打开不太安全的应用程序?
【发布时间】: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

如果您知道安全性较低的应用程序的替代方案,或者您发现代码中有错误,请发表评论。

【问题讨论】:

    标签: php xampp gmail


    【解决方案1】:

    没有。

    Google 移除了对安全性较低的应用程序的支持。

    他们没有删除一种启用它的方法,同时留下了一个会使弃用毫无意义的后门。

    如果您想使用 GMail 作为您的电子邮件后端,请使用 their API。如果您想继续使用 SMTP,则需要寻找其他电子邮件服务。

    【讨论】:

    • 感谢您的回答。你对我应该如何在 xampp(localhost) 中处理电子邮件 OTP 有什么建议吗?
    【解决方案2】:

    Google Workspace 几乎所有服务都迁移到 Oauth 2.0 协议,即使 gmail 很快也不会接受 IMAP 之类的协议来检查邮件,并且 smtp 将被接受,但似乎 SMTP 很快就会被弃用

    Google 和 Microsoft 宣布弃用基本身份验证 他们在 2022 年的电子邮件服务。两家公司都认为 Basic 认证作为过时的行业标准,因此它们是 建议其客户转向基于 OAuth 2.0 令牌的授权。

    来源:Article Deprecation Basic Auth

    也许可以帮助你这个教程Tutorial use of Oauth to send

    【讨论】:

      猜你喜欢
      • 2018-09-13
      • 2022-08-03
      • 1970-01-01
      • 1970-01-01
      • 2014-12-13
      • 2017-09-30
      • 1970-01-01
      • 2011-02-16
      • 2013-05-04
      相关资源
      最近更新 更多