我想在 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消息吗?
MODIFIED BLOCK #2 我尝试按照提供的链接进行操作,然后打开了以下说明:
当您想要确保安全性较低的应用程序对所有人都无法访问时,请使用此设置。登录您的 Google 管理控制台。使用管理员帐户登录,而不是您当前的帐户 MyNick@gmail.com
... 谁是我的管理员?快速定义:为公司、学校或团体管理 Google 服务或设备的人。您的公司、学校或群组中的某个人 您当前的帐户 MyNick@gmail.com 不是由管理员管理的。该帐户未与任何公司、学校或团体关联。相反,它是一个免费的 Google 帐户,您可以自行管理。
但是阅读我错过的文档,因为我是免费的 Google 帐户,有没有办法让自己成为管理员?如果是,请指出在哪里以及如何?
修改块#3:在我的 conf 文件中使用 587 端口: sudo nano /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
须藤纳米 /etc/ssmtp/revaliases :
root:MYNICK@gmail.com:smtp.gmail.com:587
修改这些文件后,我运行命令 service apache2 restart
并测试发送电子邮件
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的安全方法是什么,没有水滴损坏?在某些情况下,我不确定是否要重新启动某些服务,我更喜欢重新启动系统...
修改块#4:感谢您的反馈!我尝试按照您的说明进行操作:1)我激活了两因素身份验证:https ://imgur.com/a/azIZCY0 。但是,如果我对这些应用程序做些什么呢?
2) 我得到了密码https://imgur.com/a/ZddUZ31,格式为 XXXX XXXX XXXX XXXX
3)创建密码后,我得到了下一页https://imgur.com/a/1qkQLDN:
4)你提到
“在你的 .env 文件中使用应用密码”</p>
哪个必须是此密码的 var 名称?像
AuthPass=MYPASSWORD # password without spaces in it?
在 /etc/ssmtp/ssmtp.conf 或其他名称中?我只需要生成这个新密码吗?
谢谢!