gpt4 book ai didi

php - Laravel amazon ses 给出 Swift_TransportException

转载 作者:行者123 更新时间:2023-12-04 16:07:58 31 4
gpt4 key购买 nike

所以我遵循了如何使用 laravelamazon simple mail service 设置邮件的指南>

在我的 mail.php

    'driver' => env('ses', 'smtp'),

这是我的邮件类:

namespace App\Mail;

use App\rental_request;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class AccountDetails extends Mailable
{
use Queueable, SerializesModels;

protected $user;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($user)
{
$this->user = $user;
}

/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->view('mail.accountdetails')
->with([
'password' => $this->user->password,
'name' => $this->user->username,
]);
}
}

当我尝试发送邮件时,我得到以下信息:

enter image description here

谁能告诉我我错过了什么?

我的mail.php:

return [

/*
|--------------------------------------------------------------------------
| Mail Driver
|--------------------------------------------------------------------------
|
| Laravel supports both SMTP and PHP's "mail" function as drivers for the
| sending of e-mail. You may specify which one you're using throughout
| your application here. By default, Laravel is setup for SMTP mail.
|
| Supported: "smtp", "sendmail", "mailgun", "mandrill", "ses",
| "sparkpost", "log", "array"
|
*/

'driver' => env('ses', 'smtp'),

/*
|--------------------------------------------------------------------------
| SMTP Host Address
|--------------------------------------------------------------------------
|
| Here you may provide the host address of the SMTP server used by your
| applications. A default option is provided that is compatible with
| the Mailgun mail service which will provide reliable deliveries.
|
*/

'host' => env('MAIL_HOST', 'smtp.mailgun.org'),

/*
|--------------------------------------------------------------------------
| SMTP Host Port
|--------------------------------------------------------------------------
|
| This is the SMTP port used by your application to deliver e-mails to
| users of the application. Like the host we have set this value to
| stay compatible with the Mailgun e-mail application by default.
|
*/

'port' => env('MAIL_PORT', 587),

/*
|--------------------------------------------------------------------------
| 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', 'hello@example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],

/*
|--------------------------------------------------------------------------
| E-Mail Encryption Protocol
|--------------------------------------------------------------------------
|
| Here you may specify the encryption protocol that should be used when
| the application send e-mail messages. A sensible default using the
| transport layer security protocol should provide great security.
|
*/

'encryption' => env('MAIL_ENCRYPTION', 'tls'),

/*
|--------------------------------------------------------------------------
| SMTP Server Username
|--------------------------------------------------------------------------
|
| If your SMTP server requires a username for authentication, you should
| set it here. This will get used to authenticate with your server on
| connection. You may also set the "password" value below this one.
|
*/

'username' => env('MAIL_USERNAME'),

'password' => env('MAIL_PASSWORD'),

/*
|--------------------------------------------------------------------------
| Sendmail System Path
|--------------------------------------------------------------------------
|
| When using the "sendmail" driver to send e-mails, we will need to know
| the path to where Sendmail lives on this server. A default path has
| been provided here, which will work well on most of your systems.
|
*/

'sendmail' => '/usr/sbin/sendmail -bs',

/*
|--------------------------------------------------------------------------
| 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'),
],
],

];

我的 .Env 文件:

    APP_NAME=*****
APP_ENV=local
APP_KEY=base64:S3RvGYDc4ApvYauVV8Q6haaX2cFC0wWneGFSoP1z2BQ=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=****
DB_USERNAME=****
DB_PASSWORD=****

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379php

MAIL_DRIVER=ses
MAIL_HOST=email-smtp.eu-west-1.amazonaws.com
MAIL_PORT=25
MAIL_USERNAME=info
MAIL_PASSWORD=***
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

SES_KEY=****
SES_SECRET=****

最佳答案

看来您需要将 .env 文件中的 MAIL_DRIVER 变量设置为 ses,然后更改您的 mail.php 以匹配...

替换

'driver' => env('ses', 'smtp'),

'driver' => env('MAIL_DRIVER', 'smtp'),

我怀疑的问题是 env('ses', 'smtp') 不会返回 ses,它会在您的 .env 文件中查找名为 ses 并返回它的值。

关于php - Laravel amazon ses 给出 Swift_TransportException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48009818/

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