我正在使用Swiftmail通过gmail发送电子邮件。我已经在.env中配置了MAILER_URL。但是我的密码中有一个特殊字符。我了解到,当有特殊字符时,您必须对密码进行编码,但我不知道如何。
# For Gmail as a transport, use: "gmail://username:password@localhost"
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
# Delivery is disabled by default via "null://localhost"
MAILER_URL=gmail://[email protected]:landaB/24@localhost
###< symfony/swiftmailer-bundle ###```
其中的值需要使用RFC 3986进行编码。实际上,您可以使用PHP urlencode()
。
因此,值:landaB/24
变为:landaB%2F24