我在我正在维护的 Laravel 5.7 应用程序 (admin.my-app.com) 中拥有来自 aws 的以下配置。
我的.env
MAIL_MAILER=ses
SES_KEY=aws_key_here
SES_KEY_SECRET=aws_secret_key_here
SES_REGION=us-east-1
MAIL_FROM[email protected]
MAIL_FROM_NAME="${APP_NAME}"
我的配置/mail.php
<?php
return [
'default' => env('MAIL_MAILER', 'smtp'),
//other configs
我的配置/services.php
<?php
return [
'ses' => [
'key' => env('SES_KEY'),
'secret' => env('SES_KEY_SECRET'),
'region' => env('SES_REGION', 'us-east-1'),
],
//other configs
触发电子邮件发送的代码
public function approveKyc(Request $request, $userId)
{
$model = User::on('mysql2')->find($userId);
$this->actionKyc($userId, 'is_verified');
$data = [
'category' => 'approved',
'title' => __('messages.kyc.approved.title'),
'body' => __('messages.kyc.approved.body'),
'senderRole' => UserNotificationData::ROLE_ADMIN,
];
$model->notify(new ModelNotification($data));
# send e-mail notification
$notification = new KycApproved();
$model->notify($notification);
return response()->json([
'name' => 'New KYC Docs',
'status' => 'Approved'
]);
}
我还检查了 Composer 文件 "aws/aws-sdk-php": "^3.86", 已安装。
使用上面的代码我收到错误消息
异常 : “Swift_TransportException” 文件 : “/var/www/my-app/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php” 线 : 第460章 信息 : “预期响应代码 354,但收到代码“503”,并显示消息“预期 503 RCPT 命令” ”“
我测试了使用 mailtrap 发送电子邮件,效果很好。我还在另一个带有子域 (api.myapp.com) 的 laravel 10 应用程序中使用上述 aws 配置。在那里工作得很好。
任何人都可以帮我弄清楚我在这里缺少什么吗?
AWS SES 有一个“沙盒”模式,有一些限制。由于这些限制,您只能将邮件发送到经过验证的电子邮件地址或域,或者发送到 Amazon SES 邮箱模拟器。但是,如果您在沙盒模式下尝试发送到未经验证的电子邮件地址,SES 将拒绝发送请求。在产品中使用之前,您应该获得 AWS 团队的批准。