繁体   English   中英

Laravel 5.7:通过 AWS SES 的按需电子邮件通知将我的收件人电子邮件视为发件人电子邮件并希望它被验证地址

[英]Laravel 5.7: On-Demand e-mail Notification via AWS SES treats my recipient e-mail as a sender e-mail and wants it to be verified address

我想在 Laravel 5.7 中发送一个简单的按需电子邮件通知

我去了 AWS SES 并在电子邮件地址下添加了do-not-reply@foo作为发件人。 然后我点击do-not-reply@foo上的验证链接进行确认。

在此处输入图片说明

我配置了我的.env

MAIL_FROM_ADDRESS=do-not-reply@foo
MAIL_FROM_NAME="Foo System"
MAIL_DRIVER=smtp
MAIL_HOST=email-smtp.us-west-2.amazonaws.com
MAIL_PORT=587
MAIL_USERNAME=xxx
MAIL_PASSWORD=xxx
MAIL_ENCRYPTION=tls

我从这里获取了用户名和密码:

在此处输入图片说明

我做了php artisan config:clearphp artisan cache:clear

现在就我的 PHP 代码而言,我有:

$this->notificationClass = (new ReflectionClass($notificationClass))->getShortName();
$this->notificationData = $notificationData;
$this->notification
    ->route('slack', config('logging.channels.slack.url')) // slack works great all the time
    ->route('mail', 'my-inbox-address-123@gmail.com') // this is address where I want notification to be sent
    ->notify(new $notificationClass(
        $this->getNotificationTitle(),
        $this->getNotificationContent()
    ));

$notificationClass的内容是:

<?php

namespace App\Notifications\Sync;

use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\SlackMessage;

class SyncSuccessfullyCompletedNotification extends AbstractBaseSyncNotification
{
    public function toSlack()
    {
        return (new SlackMessage)
            ->success()
            ->content(sprintf('*Synchronization Successful*```%s```', $this->message));
    }

    public function toMail()
    {
        return (new MailMessage)
            ->from(config('mail.from.address'), config('mail.from.name'))
            ->subject($this->title)
            ->view('mail.notifications.sync_successfully_completed_notification', [
                'content' => sprintf('<pre>%s</pre>', $this->message),
            ]);
    }
}

所以my-inbox-address-123@gmail.com只是我的 gmail 公司收件箱。 当我执行负责做某事并发送此通知的工匠命令时,我得到:

Swift_TransportException :预期响应代码 250,但得到代码“554”,消息“554 消息被拒绝:电子邮件地址未验证。以下身份未能在 US-WEST-2 区域进行检查:my-inbox-address-123@gmail。 com”

在/home/vagrant/Code/iosportal/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:457 453| $this->eventDispatcher->dispatchEvent($evt, 'responseReceived'); 454| 第455话第456话如果(!$有效){

第457话 $this->throwException(new Swift_TransportException('Expected response code '.implode('/', $wanted).' 但得到代码 "'.$code.'", with message "'.$response.'"', $代码)); 第458话第459话 460| 461| /** 使用序列号获取完整的多行响应 */

异常跟踪:

1 Swift_Transport_AbstractSmtpTransport::assertResponseCode("554 消息被拒绝:电子邮件地址未验证。以下身份在 US-WEST-2 区域检查失败:my-inbox-address-123@gmail.com ") /home/vagrant/Code /iosportal/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:341

2 Swift_Transport_AbstractSmtpTransport::executeCommand(" . ", []) /home/vagrant/Code/iosportal/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php:305

请使用参数 -v 查看更多详细信息。

为什么? 我不明白这个。 我的发件人已通过验证,为什么要验证收件人?

事实上,当我将此消息从经过验证的帐户发送到同一个经过验证的帐户时,电子邮件会正确到达,但这是无稽之谈。

您的帐户必须处于sandbox模式,这意味着必须验证每个电子邮件地址。

检查您是否处于沙盒模式:

  1. 登录AWS 管理控制台
  2. 选择您的地区。
  3. 在电子邮件发送下选择发送统计。
  4. 如果您处于沙盒模式,您会看到一条横幅告诉您。

要退出沙盒模式:

  1. 登录AWS 管理控制台
  2. 在支持中心打开SES 发送限制增加案例。
  3. 完成表格。 如果您计划从多个地区发送,请对每个地区重复此操作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM