我正在使用 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/