0

鉴于 5.7 laravel 应用程序,我使用 themsaid/laravel-mail-preview 插件来测试使用 snowfire/beautymail 模板发送的电子邮件,为此在我本地项目的 .env 中,我有以下选择:

MAIL_DRIVER=preview
# MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

工作正常,并复制到我本地系统生成的电子邮件的“/storage/email-previews”子目录中。

但是移动到我的服务器应用程序(数字海洋下的 ubuntu 18)我遇到了一个问题,即发送电子邮件而接收者没有收到它。在我的服务器上,我安装了 ssmtp 并在文件 /etc/ssmtp/ssmtp.conf 中添加了我的 gmail 帐户的信用,当我发送带有 mail($to, $subject, $message, $headers) 功能的测试电子邮件时,接收者会收到这些电子邮件还可以

但是,为什么我没有收到使用雪火/美容邮件模板发送的电子邮件?

在我的服务器应用程序的 .env 中:

MAIL_DRIVER=smtp
# MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=587

MAIL_USERNAME=gmailnick@gmail.com   # the same parameters I have in /etc/ssmtp/ssmtp.conf
MAIL_PASSWORD=XXXXXXXXXXXXXXXX      # my gmail factor authentication password

MAIL_ENCRYPTION=null

在日志中我看到

# grep -riI ssmtp /var/log

/var/log/syslog.1:Nov  5 23:34:06 nsn-do-lamp sSMTP[3432]: Sent mail for root@smtp.gmail.com:587 (221 2.0.0 closing connection w18-v6sm13037750wrn.66 - gsmtp) uid=0 username=root outbytes=860
/var/log/syslog.1:Nov  6 00:34:06 nsn-do-lamp sSMTP[4242]: Creating SSL connection to host
/var/log/syslog.1:Nov  6 00:34:06 nsn-do-lamp sSMTP[4242]: SSL connection using ECDHE_RSA_CHACHA20_POLY1305
/var/log/syslog.1:Nov  6 00:34:08 nsn-do-lamp sSMTP[4242]: Sent mail for root@smtp.gmail.com:587 (221 2.0.0 closing connection b71-v6sm476787wma.13 - gsmtp) uid=0 username=root outbytes=860
/var/log/syslog.1:Nov  6 01:34:07 nsn-do-lamp sSMTP[5342]: Creating SSL connection to host
/var/log/syslog.1:Nov  6 01:34:07 nsn-do-lamp sSMTP[5342]: SSL connection using ECDHE_RSA_CHACHA20_POLY1305
/var/log/syslog.1:Nov  6 01:34:09 nsn-do-lamp sSMTP[5342]: Sent mail for root@smtp.gmail.com:587 (221 2.0.0 closing connection c24-v6sm77924472wre.44 - gsmtp) uid=0 username=root outbytes=860
/var/log/syslog.1:Nov  6 02:34:07 nsn-do-lamp sSMTP[6155]: Creating SSL connection to host
/var/log/syslog.1:Nov  6 02:34:07 nsn-do-lamp sSMTP[6155]: SSL connection using ECDHE_RSA_CHACHA20_POLY1305
/var/log/syslog.1:Nov  6 02:34:08 nsn-do-lamp sSMTP[6155]: Sent mail for root@smtp.gmail.com:587 (221 2.0.0 closing connection m13-v6sm6126322wrw.14 - gsmtp) uid=0 username=root outbytes=860
/var/log/syslog.1:Nov  6 03:34:07 nsn-do-lamp sSMTP[7181]: Creating SSL connection to host
/var/log/syslog.1:Nov  6 03:34:08 nsn-do-lamp sSMTP[7181]: SSL connection using ECDHE_RSA_CHACHA20_POLY1305
/var/log/syslog.1:Nov  6 03:34:09 nsn-do-lamp sSMTP[7181]: Sent mail for root@smtp.gmail.com:587 (221 2.0.0 closing connection t13-v6sm26521034wrn.22 - gsmtp) uid=0 username=root outbytes=860
/var/log/syslog.1:Nov  6 04:34:04 nsn-do-lamp sSMTP[7905]: Creating SSL connection to host
/var/log/syslog.1:Nov  6 04:34:04 nsn-do-lamp sSMTP[7905]: SSL connection using ECDHE_RSA_CHACHA20_POLY1305
/var/log/syslog.1:Nov  6 04:34:06 nsn-do-lamp sSMTP[7905]: Sent mail for root@smtp.gmail.com:587 (221 2.0.0 closing connection v11-v6sm12069528wrt.40 - gsmtp) uid=0 username=root outbytes=860
/var/log/syslog.1:Nov  6 05:34:05 nsn-do-lamp sSMTP[8799]: Creating SSL connection to host
/var/log/syslog.1:Nov  6 05:34:05 nsn-do-lamp sSMTP[8799]: SSL connection using ECDHE_RSA_CHACHA20_POLY1305
/var/log/syslog.1:Nov  6 05:34:07 nsn-do-lamp sSMTP[8799]: Sent mail for root@smtp.gmail.com:587 (221 2.0.0 closing connection g16-v6sm20220322wrr.38 - gsmtp) uid=0 username=root outbytes=860

我在我的服务器上设置了 cron,上面的消息看起来像来自这个发送电子邮件的 cron...

是我服务器的 .env 文件的问题吗?有什么问题?

修改块#2:我修改了我的应用程序的 .env :

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587

MAIL_USERNAME=gmailnick@gmail.com   # the same parameters I have in /etc/ssmtp/ssmtp.conf
MAIL_PASSWORD=XXXXXXXXXXXXXXXX      # my gmail factor authentication password

MAIL_ENCRYPTION=null

并清除缓存但发送电子邮件我收到错误:

Expected response code 250 but got code "530", with message "530 5.7.0 Must issue a STARTTLS command first. r1-v6sm13862441wrt.59 - gsmtp "

怎么了 ?

谢谢!

4

0 回答 0