【问题标题】:Laravel won't send through AWS SES SMTPLaravel 不会通过 AWS SES SMTP 发送
【发布时间】:2017-06-02 16:31:52
【问题描述】:

我正在运行 Laravel 5.4.24,但无法通过 Amazon SES SMTP 发送它。

但是,当我下载 SwiftMailer 并独立运行时,我可以。

工作..

require("vendor/autoload.php");

// Create the Transport
$transport = new Swift_SmtpTransport('email-smtp.us-west-2.amazonaws.com', 587, 'tls');
$transport->setUsername('A**************A');
$transport->setPassword('A****************************m');

// Create the Mailer using your created Transport
$mailer = new Swift_Mailer($transport);

// Create a message
$message = new Swift_Message('Wonderful Subject');

$message->setFrom(['noreply@su*****th.com' => 'John Doe']);

$message->setTo(['j*******@gmail.com' => 'Jamie']);

$message->setBody('Here is the message itself');

// Send the message
$result = $mailer->send($message);

Laravel 设置不起作用

MAIL_DRIVER=smtp
MAIL_HOST=email-smtp.us-west-2.amazonaws.com
MAIL_PORT=587
MAIL_USERNAME=A****************A
MAIL_PASSWORD=A************************m
MAIL_ENCRYPTION=tls

即使凭据相同,我也得到了

Expected response code 250 but got code "530", with message "530 Authentication required

我试过了

php artisan queue:restart
php artisan config:cache

这就是我在代码中使用 Mail 的方式

Mail::send('emails.verify', $data, function($message) use ($data)
{
    $message->from('noreply@su*****h.com', "Jamie - ****");
    $message->subject("Please verify your email address");
    $message->to($data['email']);
});

但没有运气。

有什么想法吗?

【问题讨论】:

  • 我之前使用 .env 时遇到过问题,尝试将配置直接放在 config/mail.php 中
  • 别忘了 php artisan config:cache
  • 已经尝试了这两个,恐怕没有运气:-(
  • 您确定您使用的是 SES SMTP 用户名和密码,而不是帐户访问权限和密码吗?
  • 是的。在 swiftmailer 中独立工作,但不能在 laravel 中工作,让其他一些人检查凭据。一切看起来都很好。奇数。

标签: php laravel email swiftmailer amazon-ses


【解决方案1】:

SES 密钥和区域在 config/services.php 文件中配置。

所以对我来说,问题是即使我已经在我的其他 AWS 配置中将默认区域设置为 us-west-2,SES 在直接设置为“us-east-1”的服务文件中使用自己的配置' 并且不使用我的 .env 文件中的现有 AWS 密钥。

【讨论】:

    猜你喜欢
    • 2018-08-13
    • 2018-06-24
    • 1970-01-01
    • 2018-10-12
    • 2017-08-03
    • 2014-12-30
    • 2020-11-25
    • 2016-11-17
    • 1970-01-01
    相关资源
    最近更新 更多