配置Matomo使用AWS Signature Version 4发送邮件遇认证问题求助
我的Matomo实例持续记录以下日志:
2022-08-31 06:57:46 SERVER -> CLIENT: 535 Signature Version 2 is deprecated for use with SES from March 26, 2021. From that date on, we are progressively rejecting such requests. To resolve the issue, you must migrate to Signature Version 4. If you created your SMTP credentials in the SES Console, please create new credentials and replace the former ones. If you are deriving Signature Version 2 credentials from a IAM user, please start using the Signature Version 4 algorithm: https://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentia
2022-08-31 06:57:46 SMTP ERROR: User & Password command failed: 535 Signature Version 2 is deprecated for use with SES from March 26, 2021. From that date on, we are progressively rejecting such requests. To resolve the issue, you must migrate to Signature Version 4. If you created your SMTP credentials in the SES Console, please create new credentials and replace the former ones. If you are deriving Signature Version 2 credentials from a IAM user, please start using the Signature Version 4 algorithm: https://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentia
2022-08-31 06:57:46 SMTP Error: Could not authenticate.
于是我创建了新的SMTP用户,预期它会自动使用新签名,随后从AWS获取了三个值:
- IAM用户名
- SMTP用户名
- SMTP密码
但现在连接完全无法正常工作,我的config.ini.php配置如下:
[mail] transport = "smtp" port = 25 host = "email-smtp.eu-west-1.amazonaws.com" type = "Login" encryption = "tls" username = "[[Smtp Username]]" password = "[[Smtp Password]]"
当前报错信息:
Uncaught exception: /var/www/html/vendor/phpmailer/phpmailer/src/PHPMailer.php(2178): SMTP Error: Could not authenticate. [Query: , CLI mode: 1]
我是否需要修改type或encryption配置来恢复邮件发送功能?
不需要修改type或encryption配置,问题出在其他环节,按以下步骤排查:
- 更换SMTP端口:AWS SES的25端口常被服务器提供商封禁,建议改用465(对应
encryption = "ssl")或587(保持encryption = "tls")端口,优先尝试465。 - 验证凭证正确性:确认填入的是AWS SES生成的SMTP专用用户名和密码,而非IAM用户的登录凭证;同时确保该SMTP对应的IAM用户拥有SES邮件发送权限(比如附加
AmazonSESFullAccess策略)。 - 核对区域匹配:检查
host地址email-smtp.eu-west-1.amazonaws.com是否和你的SES服务所在区域完全一致,区域不匹配会直接导致认证失败。 - 检查PHPMailer版本:Matomo依赖的PHPMailer若版本过低可能不支持Signature Version 4,尝试升级Matomo到最新稳定版,或手动更新PHPMailer至支持该签名版本的版本。
内容的提问来源于stack exchange,提问作者tobias47n9e

