如何为swiftmailer .env使用特殊字符对密码进行编码

问题描述 投票:-1回答:1

我正在使用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 ###```
php symfony4 swiftmailer
1个回答
0
投票

其中的值需要使用RFC 3986进行编码。实际上,您可以使用PHP urlencode()

因此,值:landaB/24变为:landaB%2F24

© www.soinside.com 2019 - 2024. All rights reserved.