上下文
在Symfony 4.3中,引入了新的电子邮件程序。
查看此处:
- https://symfony.com/blog/new-in-symfony-4-3-mailer-component
- https://symfony.com/doc/4.4/mailer.html。
对于SMTP传输,已确定ENV变量中的Dsn具有以下格式:
MAILER_Dsn=smtp://user:pass@smtp.example.com
问题
编写Dsn时如何处理用户名和密码中的特殊字符?
让我们假设凭据是:
username: alice@example.com
password: the:password:is:difficult
像这样的设置很可能会失败:
MAILER_Dsn=smtp://alice@example.com:the:password:is:difficult@smtp.example.com
我应该如何编码/转义内容?正确的Dsn是什么?