我试图检查一个错误,我遇到了一个奇怪的行为
我在Nova有一个动作,TestMailsCampaign
它调用一个 Job 来排队一系列电子邮件。
这个动作有一个允许改变邮件传输的操作
在将操作发送到 Job 类之前,使用 ray 检查并记录邮件配置config('mail.mailers.smtp')
的数组值 ,我再次检查,我发现两者不同并且是失败的根源。在此类中,基于 .env vars 的所有配置值都失败。TestMailsCampaign
SendMailsTestJob
配置/邮件.php
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.fake.tld'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'auth_mode' => null,
],
.env
MAIL_HOST=myhost.domain.tld
MAIL_PORT=587
MAIL_USERNAME=noreply@myhost.domain.tld
MAIL_PASSWORD="MyPaSsW0Rd"
MAIL_ENCRYPTION=tls
TestEmailCampaign(操作)
public function handle(ActionFields $fields, Collection $models)
{
...
Log::debug(json_encode(config('mail.mailers.smtp')));
// Logs show correct config with values in .env
// [2022-01-04 06:25:10] local.DEBUG: {"transport":"smtp","host":"myhost.domain.tld","port":"587","encryption":"tls","username":"noreply@myhost.domain.tld","password":"MyPaSsW0Rd","timeout":null,"auth_mode":null}
// Logic
App\Jobs\SendMailsTestJob::dispatch($model, $fields->mailables, $recipients, $fields->mailer);
}
发送邮件工作
public function handle()
{
// Logic
ray($mailer, config('mail.mailers.smtp'));
Log::debug(json_encode(config('mail.mailers.smtp')));
// Logs show incorrect values. Emoty username, password,...
// [2022-01-04 06:25:12] local.DEBUG: {"transport":"smtp","host":"myhost.domain.tld","port":"587","encryption":null,"username":"","password":null,"timeout":null,"auth_mode":null}
Mail::mailer($mailer)
->to($subscriber->email)
->send(new ConfirmationMail($campaign, $subscriber, $campaign_subscriber));
}
我已经尝试在 mail.conf 中放置正确值的代码。是wordkaorund,但不正确。
有任何想法吗?