php - 如何使用 swiftmailer .env 的特殊字符对密码进行编码
问题描述
我正在使用 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://landabravo@gmail.com:landaB/24@localhost
###< symfony/swiftmailer-bundle ###```
解决方案
需要使用RFC 3986对值进行编码。实际上,您可以使用 PHP urlencode()
。
所以值:landaB/24
变为:landaB%2F24
推荐阅读
- javascript - 是否可以通过以编程方式触发发送功能在 whatsapp 网络中发送贴纸?
- python-3.x - 使用 Redis、Pickle、Python3 更好地处理序列化
- php - 在环境配置中设置正确的数据库主机
- pine-script - 具有多个指标 EMA、交易量和布林线的 pine 脚本
- postgresql - Postgresql:计数和一列的总和?
- python - Python 感知器训练
- ios - 为什么我的滚动不适用于 iOS Swift 中的 iPhone 12 和 iPhone 11
- ruby-on-rails - 在 Rails 单表继承中覆盖“has_many”关联“依赖”
- python - 无法单击按钮 Selenium
- sublimetext3 - Sublime Text to Bulk 从大型 XML 文件中删除元素/节点?