Laravel 错误消息:预期响应代码220,但得到的响应为空;“除此之外”;Swift“运输例外情况”;,
我遵循一个教程,在上使用passport身份验证构建API 我遵循了第1部分的内容,并通过帐户确认和通知浏览了第2部分,但最终在测试POSTMAN时遇到了一个问题。问题是,它只会在没有发送带有错误的邮件的情况下添加到数据库中。我不知道我需要在.env或mail.php中进行任何配置。当我试图配置电子邮件地址、STMP和密码时。同样的错误再次显示,我在这里看到的大多数问题都非常不同,因为大多数都与mail.php和.env有关,我不知道,因为教程链接上没有这样的问题,我甚至尝试更改mail.php和.env,我运行了php artisan cache:clear,但显示了相同的错误Laravel 错误消息:预期响应代码220,但得到的响应为空;“除此之外”;Swift“运输例外情况”;,,laravel,laravel-passport,Laravel,Laravel Passport,我遵循一个教程,在上使用passport身份验证构建API 我遵循了第1部分的内容,并通过帐户确认和通知浏览了第2部分,但最终在测试POSTMAN时遇到了一个问题。问题是,它只会在没有发送带有错误的邮件的情况下添加到数据库中。我不知道我需要在.env或mail.php中进行任何配置。当我试图配置电子邮件地址、STMP和密码时。同样的错误再次显示,我在这里看到的大多数问题都非常不同,因为大多数都与mail.php和.env有关,我不知道,因为教程链接上没有这样的问题,我甚至尝试更改mail.php
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
class SignupActivate extends Notification
{
use Queueable;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
$url = url('/api/auth/signup/activate/'.$notifiable->activation_token);
return (new MailMessage)
->subject('Confirm your account')
->line('Thanks for signup! Please before you begin, you must confirm your account.')
->action('Confirm Account', url($url))
->line('Thank you for using our application!');
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}
])
.env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=username@gmail.com
MAIL_PASSWORD=XXXXXXXXXXXXXXX
MAIL_ENCRYPTION=null
我想我能解决你的问题。您需要做的是进行严格的设置以符合mail.php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'username@gmail.com'),
'name' => env('MAIL_FROM_NAME', 'Payne Curtis'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
'log_channel' => env('MAIL_LOG_CHANNEL'),
];
因此,将您的.env更改为以下内容:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=abdulkabirojulari@gmail.com
MAIL_PASSWORD=gjcltiocmmqoutfi
MAIL_ENCRYPTION=tls
MAIL\u ENCRYPTION=tls非常重要,在
.env
中进行任何更改后,需要将其添加到.env文件,运行php artisan cache:clear
和php artisan config:cache`并重试。是,我做了所有这些您是否尝试了2-verification并确保您配置了将在.env文件中使用的应用程序密码?是的,我做了,2-way verification和应用程序密码非常感谢您。。。这救了我一天。它就像一个符咒。
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=abdulkabirojulari@gmail.com
MAIL_PASSWORD=gjcltiocmmqoutfi
MAIL_ENCRYPTION=tls