Laravel 5.7:On-Demand e-mail 通过 AWS SES 的通知将我的收件人 e-mail 视为发件人 e-mail 并希望它成为验证地址
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 中发送一个简单的 on-demand e-mail notification。
我去了 AWS SES 并在电子邮件地址下添加了 do-not-reply@foo
作为发件人。然后我在do-not-reply@foo
上点击验证link确认一下
我配置了我的 .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:clear
和 php 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 公司收件箱。当我执行负责做某事并发送此通知的 artisan 命令时,我得到:
Swift_TransportException : Expected response code 250 but got code
"554", with message "554 Message rejected: Email address is not
verified. The following identities failed the check in region
US-WEST-2: my-inbox-address-123@gmail.com "
at
/home/vagrant/Code/iosportal/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:457
453| $this->eventDispatcher->dispatchEvent($evt, 'responseReceived');
454| }
455|
456| if (!$valid) {
457| $this->throwException(new Swift_TransportException('Expected response code '.implode('/',
$wanted).' but got code "'.$code.'", with message "'.$response.'"',
$code));
458| }
459| }
460|
461| /** Get an entire multi-line response using its sequence number */
异常跟踪:
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
模式,这意味着必须验证每个电子邮件地址。
检查您是否处于沙盒模式:
- 登录AWS Management Console。
- Select 您所在的地区。
- 在电子邮件发送下选择发送统计。
- 如果您处于沙盒模式,您会看到一条横幅告诉您。
要退出沙盒模式:
- 登录AWS Management Console。
- 在支持中心打开一个 SES Sending Limit Increase 案例。
- 填写表格。如果您计划从多个区域发送,请对每个区域重复。
我想在 Laravel 5.7 中发送一个简单的 on-demand e-mail notification。
我去了 AWS SES 并在电子邮件地址下添加了 do-not-reply@foo
作为发件人。然后我在do-not-reply@foo
上点击验证link确认一下
我配置了我的 .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:clear
和 php 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 公司收件箱。当我执行负责做某事并发送此通知的 artisan 命令时,我得到:
Swift_TransportException : Expected response code 250 but got code "554", with message "554 Message rejected: Email address is not verified. The following identities failed the check in region US-WEST-2: my-inbox-address-123@gmail.com "
at /home/vagrant/Code/iosportal/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:457 453| $this->eventDispatcher->dispatchEvent($evt, 'responseReceived'); 454| } 455| 456| if (!$valid) {
457| $this->throwException(new Swift_TransportException('Expected response code '.implode('/', $wanted).' but got code "'.$code.'", with message "'.$response.'"', $code)); 458| } 459| } 460| 461| /** Get an entire multi-line response using its sequence number */
异常跟踪:
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
模式,这意味着必须验证每个电子邮件地址。
检查您是否处于沙盒模式:
- 登录AWS Management Console。
- Select 您所在的地区。
- 在电子邮件发送下选择发送统计。
- 如果您处于沙盒模式,您会看到一条横幅告诉您。
要退出沙盒模式:
- 登录AWS Management Console。
- 在支持中心打开一个 SES Sending Limit Increase 案例。
- 填写表格。如果您计划从多个区域发送,请对每个区域重复。