理由:大部分商业发信服务商例如 Sendgrid, Amazon SES 都不使用 Email 格式作为其 SMTP 用户名,使得邮件无法正常发送
具体错误的 log :
`2023/06/08 17:44:36 [error] 22474#0: *2758 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Symfony\Component\Mime\Exception\RfcComplianceException: Email "apikey" does not comply with addr-spec of RFC 2822. in $ROOT_PATH/vendor/symfony/mime/Address.php:54
Stack trace:
目前的表现:使用最新的 Release 版本,SMTP 设置为使用 外部SMTP服务器 时,看起来在发送邮件时会对设置的 SMTP 用户名的格式使用 EmailValidator 进行校验以确定其符合 RFC 2822 格式。
期望的表现:不再对 SMTP 用户名格式进行校验,仅校验 主要设定 中的发件人地址 以及 收件人地址
理由:大部分商业发信服务商例如 Sendgrid, Amazon SES 都不使用 Email 格式作为其 SMTP 用户名,使得邮件无法正常发送
具体错误的 log : `2023/06/08 17:44:36 [error] 22474#0: *2758 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Symfony\Component\Mime\Exception\RfcComplianceException: Email "apikey" does not comply with addr-spec of RFC 2822. in $ROOT_PATH/vendor/symfony/mime/Address.php:54 Stack trace:
0 $ROOT_PATH/app/Repositories/ToolRepository.php(344): Symfony\Component\Mime\Address->__construct()
1 $ROOT_PATH/include/functions.php(1588): App\Repositories\ToolRepository->sendMail()
2 $ROOT_PATH/public/mailtest.php(23): sent_mail()
3 {main}
thrown in $ROOT_PATH/vendor/symfony/mime/Address.php on line 54" while reading response header from upstream, client: 192.0.2.1, server: $DOMAIN, request: "POST /mailtest.php HTTP/2.0", upstream: "fastcgi://unix:/tmp/php-cgi-80.sock:", host: "$DOMAIN", referrer: "https://$DOMAIN/mailtest.php"`
其中
apikey
为 Sendgrid 的 SMTP 用户名,Log 中的应用根目录路径已使用$ROOT_PATH
替换、域名已使用$DOMAIN
替换