我在尝试使用 laravel auth 发送电子邮件时遇到错误。
这是我的 .env 文件
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=465
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="723f333b3e2d272137203c333f374f1f0b371f131b1e32151f131b1e5c111d1f" rel="noreferrer noopener nofollow">[email protected]</a>
MAIL_PASSWORD=myPassword
MAIL_ENCRYPTION=tls
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a2efe3ebeefde4f0edeffde3e6e6f0e7f1f19fcac7cececde2c7dac3cfd2cec78cc1cdcf" rel="noreferrer noopener nofollow">[email protected]</a>
MAIL_FROM_NAME=Example
这是我的 mail.php 文件
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 465),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
],
'ses' => [
'transport' => 'ses',
],
'mailgun' => [
'transport' => 'mailgun',
],
'postmark' => [
'transport' => 'postmark',
],
'sendmail' => [
'transport' => 'sendmail',
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
],
'log' => [
'transport' => 'log',
'channel' => env('MAIL_LOG_CHANNEL'),
],
'array' => [
'transport' => 'array',
],
'failover' => [
'transport' => 'failover',
'mailers' => [
'smtp',
'log',
],
],
],
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application.
|
*/
'from' => [
'address' => env('MAIL_FROM_ADDRESS', '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d7bfb2bbbbb897b2afb6baa7bbb2f9b4b8ba" rel="noreferrer noopener nofollow">[email protected]</a>'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
/*
|--------------------------------------------------------------------------
| Markdown Mail Settings
|--------------------------------------------------------------------------
|
| If you are using Markdown based email rendering, you may configure your
| theme and component paths here, allowing you to customize the design
| of the emails. Or, you may simply stick with the Laravel defaults!
|
*/
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
我尝试根据mail.php文件中的信息更改.env文件中MAIL_MAILER、MAIL_HOST、MAIL_PORT、MAIL_ENCRYPTION、MAIL_FROM_ADDRESS和MAIL_FROM_NAME的值。但还是不行。有人可以帮我解决这个问题吗,谢谢。
最佳答案
.env
文件。
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=465
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="abe6eae2e7f4fef8eef9e5eae6ee96c6d2eec6cac2c7ebccc6cac2c785c8c4c6" rel="noreferrer noopener nofollow">[email protected]</a> \\ Gmail mail iD
MAIL_PASSWORD=myPassword \\ Gmail App generated password
MAIL_ENCRYPTION=tls
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="470a060e0b180115080a18060303150214147a2f222b2b2807223f262a372b226924282a" rel="noreferrer noopener nofollow">[email protected]</a>
MAIL_FROM_NAME=Example
下面的链接用于生成应用程序密码。 https://support.google.com/mail/answer/185833?hl=en
或
MAIL_DRIVER=sendmail
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="88c5c9c1c4d7dddbcddac6c9c5cdb5e5f1efe5e9e1e4c8efe5e9e1e4a6ebe7e5" rel="noreferrer noopener nofollow">[email protected]</a>
MAIL_PASSWORD=******
MAIL_ENCRYPTION=tls
本地主机系统 MAIL_DRIVER=smtp 工作正常,当您在 cpanel 上上传项目时出现此错误。 .env 文件中的更改如此简单
MAIL_DRIVER 从 smtp 到 sendmail。
更多帮助还请阅读:The connection could not be established with host smtp.gmail.com?
关于laravel - 身份验证器 "LOGIN"返回 "Expected response code "23 5"but got code "53 5", with message "535 身份验证失败“。”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71672230/