amazon-web-services - Symfony Swiftmailer - 如果凭证中存在特殊字符,AWS SES 凭证将不起作用

标签 amazon-web-services symfony amazon-ses swiftmailer

我正在使用 AWS SES 通过 Symfony Swiftmailer 发送电子邮件。这工作得很好。

我在同一服务器上有第二个应用程序,我想在其中创建第二组凭据以限制风险。 IE。我们之前曾泄露过凭据,如果发生这种情况,我只希望 1 个应用程序受到影响。

对于我的第一个应用程序,我的凭据工作正常,但 key 很特殊,因为它只包含字母字符。我的第二组凭据包含“/”和“+”。

我曾与 AWS 支持人员通话,他们向我展示了我可以使用以下方式发送电子邮件

  openssl s_client -crlf -quiet -starttls smtp -connect email-smtp.ap-southeast-2.amazonaws.com:587 < SMTP.txt

其中 SMTP.txt 包含 base64 编码的凭据 ( this method )

我需要在 .env 文件中对我的凭据进行编码吗?

最佳答案

documentation on Swift Mailer警告您有关特殊字符的信息:

If the username, password or host contain any character considered special in a URI (such as +, @, $, #, /, :, *, !), you must encode them. See RFC 3986 for the full list of reserved characters or use the urlencode function to encode them.

执行如下命令来获取编码密码

<?php
    $plainpwd = "...Your password...";
    echo urlencode($plainpwd);
?>

并在您的 .env 配置中使用它。例如,

MAILER_URL=smtp://email-smtp.us-east-1.amazonaws.com:587?encryption=tls&username=YOUR_SES_USERNAME&password=YOUR_ENCODED_SES_PASSWORD

关于amazon-web-services - Symfony Swiftmailer - 如果凭证中存在特殊字符,AWS SES 凭证将不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67155819/

相关文章:

php - 我应该如何构造 Response 对象,以在 Symfony2 中提供来自数据库的图像/附件?

php - 为商店订单生成唯一的序列号

curl - 使用 curl 向 Actix 服务器发送 POST 请求失败,返回 "400 Bad Request"

amazon-web-services - 用于 DKIM 配置的 AWS SES 身份 "pending verification"

email - Amazon SES 可用于公司电子邮件

python - 如何为基于 docker 的 python3 lambda 函数配置入口点/cmd?

amazon-web-services - AWS CLI 检查 lambda 函数是否存在

amazon-web-services - aws kinesis 迭代器过期后如何刷新?

sql - 已授予 Postgres 角色但因关系错误而拒绝获得权限

mysql - 使用 Doctrine 后:schema:update --force