gpt4 book ai didi

php - 如何修复使用 gmail 发送电子邮件时出现的错误?

转载 作者:可可西里 更新时间:2023-11-01 12:19:40 24 4
gpt4 key购买 nike

我想在 Digital Ocean 下的 ubuntu 18 中的 php/laravel 应用程序中发送电子邮件,我发现了这个 https://semantiko.com/how-to-fix-php-mail-function-on-ubuntu-server/文章我填写了相关的配置文件并发送了几封电子邮件,我在控制台中找到了:

grep -riI ssmtp /var/log
...
/var/log/mail.log:Oct 24 14:05:22 nsn-do-lamp sSMTP[16500]: SSL connection using ECDHE_RSA_CHACHA20_POLY1305
/var/log/mail.log:Oct 24 14:05:22 nsn-do-lamp sSMTP[16500]: Authorization failed (534 5.7.14 https://support.google.com/mail/answer/78754 b5-v6sm5187045wrr.94 - gsmtp)
/var/log/mail.log:Oct 24 14:05:23 nsn-do-lamp sSMTP[16502]: Creating SSL connection to host
/var/log/mail.log:Oct 24 14:05:23 nsn-do-lamp sSMTP[16502]: SSL connection using ECDHE_RSA_CHACHA20_POLY1305
/var/log/mail.log:Oct 24 14:05:23 nsn-do-lamp sSMTP[16502]: Authorization failed (534 5.7.14 https://support.google.com/mail/answer/78754 t198-v6sm6776812wmd.9 - gsmtp)
/var/log/dpkg.log:2018-10-24 05:27:56 install ssmtp:amd64 <none> 2.64-8ubuntu2
/var/log/dpkg.log:2018-10-24 05:27:56 status half-installed ssmtp:amd64 2.64-8ubuntu2
/var/log/dpkg.log:2018-10-24 05:27:56 status unpacked ssmtp:amd64 2.64-8ubuntu2
/var/log/dpkg.log:2018-10-24 05:27:56 status unpacked ssmtp:amd64 2.64-8ubuntu2
/var/log/dpkg.log:2018-10-24 05:27:56 configure ssmtp:amd64 2.64-8ubuntu2 <none>
/var/log/dpkg.log:2018-10-24 05:27:56 status unpacked ssmtp:amd64 2.64-8ubuntu2
/var/log/dpkg.log:2018-10-24 05:27:56 status unpacked ssmtp:amd64 2.64-8ubuntu2
/var/log/dpkg.log:2018-10-24 05:27:56 status unpacked ssmtp:amd64 2.64-8ubuntu2
/var/log/dpkg.log:2018-10-24 05:27:56 status half-configured ssmtp:amd64 2.64-8ubuntu2
/var/log/dpkg.log:2018-10-24 05:27:56 status installed ssmtp:amd64 2.64-8ubuntu2
/var/log/syslog.1:Oct 24 05:34:07 nsn-do-lamp sSMTP[10100]: Creating SSL connection to host
/var/log/syslog.1:Oct 24 05:34:07 nsn-do-lamp sSMTP[10100]: SSL connection using ECDHE_RSA_CHACHA20_POLY1305
/var/log/syslog.1:Oct 24 05:34:07 nsn-do-lamp sSMTP[10100]: Authorization failed (534 5.7.9 https://support.google.com/mail/?p=WebLoginRequired 130-v6sm4756430wmn.7 - gsmtp)

在我的账户下 https://mail.google.com我找到了电子邮件:

Sign-in attempt was blocked
myaccount@gmail.com
Someone just used your password to try to sign in to your account from a non-Google app. Google blocked them, but you should check what happened. Review your account activity to make sure no one else has access.
CHECK ACTIVITY

点击“检查事件”按钮打开下一页https://imgur.com/a/fUKlJgO我想允许我的帐户或我自己被使用,所以我点击“否,安全帐户”并打开下一页 https://imgur.com/a/LfIDTB4

这对我来说很奇怪,因为我不需要更改密码。我想允许邮件服务使用我的 gmail.com 帐户。

你能说说哪里不对吗?
我是否误解了 Gmail 邮件?

修改 block # 2我尝试按照提供的链接打开下一个说明:

Use this setting when you want to ensure that access by a less secure app is unavailable to all. Sign in to your Google Admin console. Sign in using an administrator account, not your current account MyNick@gmail.com

... Who is my administrator? Quick definition: A person who manages Google services or devices for a company, school, or group. Someone in your company, school, or group Your current account, MyNick@gmail.com, isn’t managed by an administrator. The account isn’t associated with any company, school, or group. Instead, it’s a free Google Account that you can manage yourself.

但是阅读我错过的文档,因为我有免费的 Google 帐户,有没有办法让我自己成为管理员?如果是,请指出地点和方式?

修改 block #3:在我的 conf 文件中使用了 587 端口:须藤纳米/etc/ssmtp/ssmtp.conf :

root=MYNICK@gmail.com
mailhub=smtp.gmail.com:587
hostname=smtp.gmail.com:587
UseSTARTTLS=YES
AuthUser=MYNICK@gmail.com
AuthPass=MYPASSWORD
FromLineOverride=YES
UseTLS=YES

sudo nano/etc/ssmtp/revaliases :

root:MYNICK@gmail.com:smtp.gmail.com:587

修改这些文件后,我运行命令服务apache2重启

并测试发送电子邮件 我没有在我的电子邮件中收到电子邮件我在下一个日志中看到很多“授权失败”错误

grep -riI ssmtp /var/log
var/log/syslog.1:Oct 30 00:34:04 nsn-do-lamp sSMTP[24892]: Creating SSL connection to host
/var/log/syslog.1:Oct 30 00:34:04 nsn-do-lamp sSMTP[24892]: SSL connection using ECDHE_RSA_CHACHA20_POLY1305
/var/log/syslog.1:Oct 30 00:34:05 nsn-do-lamp sSMTP[24892]: Authorization failed (534 5.7.14 https://support.google.com/mail/answer/78754 y76-v6sm12958494wmd.37 - gsmtp)
/var/log/syslog.1:Oct 30 01:34:04 nsn-do-lamp sSMTP[25660]: Creating SSL connection to host
/var/log/syslog.1:Oct 30 01:34:04 nsn-do-lamp sSMTP[25660]: SSL connection using ECDHE_RSA_CHACHA20_POLY1305
/var/log/syslog.1:Oct 30 01:34:04 nsn-do-lamp sSMTP[25660]: Authorization failed (534 5.7.14 https://support.google.com/mail/answer/78754 60-v6sm16580038wra.35 - gsmtp)
/var/log/syslog.1:Oct 30 02:34:05 nsn-do-lamp sSMTP[26444]: Creating SSL connection to host
/var/log/syslog.1:Oct 30 02:34:05 nsn-do-lamp sSMTP[26444]: SSL connection using ECDHE_RSA_CHACHA20_POLY1305
/var/log/syslog.1:Oct 30 02:34:05 nsn-do-lamp sSMTP[26444]: Authorization failed (534 5.7.14 https://support.google.com/mail/answer/78754 t16-v6sm274794wrr.12 - gsmtp)
/var/log/syslog.1:Oct 30 03:34:06 nsn-do-lamp sSMTP[27101]: Creating SSL connection to host
/var/log/syslog.1:Oct 30 03:34:07 nsn-do-lamp sSMTP[27101]: SSL connection using ECDHE_RSA_CHACHA20_POLY1305
/var/log/syslog.1:Oct 30 03:34:07 nsn-do-lamp sSMTP[27101]: Authorization failed (534 5.7.14 https://support.google.com/mail/answer/78754 m16-v6sm13164091wmd.35 - gsmtp)
/var/log/syslog.1:Oct 30 04:34:04 nsn-do-lamp sSMTP[27852]: Creating SSL connection to host
/var/log/syslog.1:Oct 30 04:34:04 nsn-do-lamp sSMTP[27852]: SSL connection using ECDHE_RSA_CHACHA20_POLY1305
/var/log/syslog.1:Oct 30 04:34:05 nsn-do-lamp sSMTP[27852]: Authorization failed (534 5.7.14 https://support.google.com/mail/answer/78754 143-v6sm17450782wmv.6 - gsmtp)
/var/log/syslog.1:Oct 30 05:34:04 nsn-do-lamp sSMTP[28734]: Creating SSL connection to host
/var/log/syslog.1:Oct 30 05:34:04 nsn-do-lamp sSMTP[28734]: SSL connection using ECDHE_RSA_CHACHA20_POLY1305
/var/log/syslog.1:Oct 30 05:34:04 nsn-do-lamp sSMTP[28734]: Authorization failed (534 5.7.14 https://support.google.com/mail/answer/78754 b5-v6sm1822874wrf.15 - gsmtp)

1) 可以是一些更多的服务,我需要重新启动 apache2

2) 在我看来,这些日志消息并不是最后的,因为正在运行:

 # date
Tue Oct 30 12:02:40 UTC 2018

我看到了时差,好像没有最后的消息行有没有办法清除 ssmtp 日志?

3) 在 Digital Ocean 下重启 ubuntu 18 的安全方法是什么,没有液滴损坏?在某些情况下,我不确定是否要重新启动一些service 我更喜欢重启系统...

修改 block #4:感谢您的反馈意见!我试着按照你的指示去做:1) 我激活了双因素身份验证:https://imgur.com/a/azIZCY0 .但是,如果我对这些应用程序做了什么?

2) 我得到了密码 https://imgur.com/a/ZddUZ31格式为 XXXX XXXX XXXX XXXX

3) 创建密码后,我得到了下一页 https://imgur.com/a/1qkQLDN :

4) 你提到了

“use the app password in your .env file”

这必须是这个密码的 var 名称?喜欢在

AuthPass=MYPASSWORD # password without spaces in it?

在/etc/ssmtp/ssmtp.conf 或其他名称中?我只需要生成这个新密码吗?

谢谢!

最佳答案

允许安全性较低的应用访问帐户

  1. 登录到您的 Google 管理控制台。
  2. 点击安全 > 基本设置。
  3. 在安全性较低的应用下,选择转至安全性较低的应用的设置。
  4. 在子窗口中,选择允许用户管理他们对安全性较低的应用的访问单选按钮。

一旦您设置了允许用户管理他们对 安全性较低的应用程序会影响所选组中的受影响用户或 组织单位将能够切换安全性较低的访问权限 应用自行开启或关闭。

引用 Allow or disallow less secure apps to access accounts

关于php - 如何修复使用 gmail 发送电子邮件时出现的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52971454/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com