gpt4 book ai didi

laravel - 错误消息 : Expected response code 220 but got an empty response"with exception "Swift_TransportException",

转载 作者:行者123 更新时间:2023-12-04 01:47:21 27 4
gpt4 key购买 nike

enter image description here我正在按照教程使用 enter link description here 上的护照身份验证构建 API。
我遵循了第 1 部分并通过 完成了第 2 部分。帐户确认和通知 但是当我在 POSTMAN 上进行测试时最终遇到了问题。问题是,它确实会添加到数据库中,只是没有发送带有错误的邮件。我不知道我需要在 .env 或 mail.php 中做任何配置。当我尝试配置电子邮件地址、STMP 和密码时。同样的错误再次显示,我在这里看到的大多数问题都大不相同,因为大多数问题都与 mail.php 和 .env 有关,我不知道,因为教程链接上没有这样的问题,我什至试图更改邮件.php 和 .env,我跑了 php artisan 缓存:清除 但显示相同的错误。

<?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 [
//
];
}
}

我也做过,两种认证方式
邮箱.php

返回 [
'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=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_ENCRYPTION=tls 非常必要,需要添加到 .env 文件中

关于laravel - 错误消息 : Expected response code 220 but got an empty response"with exception "Swift_TransportException",,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54787348/

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