You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Magento 2邮件模板跳转带Token外部URL失败求助

解决Magento 2密码重置邮件模板跳转外部带Token URL的问题

你的问题出在误用了Magento的this.getUrl()方法——这个方法是用来生成内部路由URL的,直接传入完整外部URL会导致解析错误,生成的链接不符合预期。

正确的修改方式

不需要依赖getUrl(),直接拼接外部URL和Token参数即可:

<a href="https://www.my-simple.com/reset-password/?token={{var $customer.rp_token}}" target="_blank">{{trans "Set a New Password"}}</a>

额外注意事项

  • 清理缓存:修改模板后必须执行以下命令清除Magento缓存,确保新模板生效:
    bin/magento cache:clean
    bin/magento cache:flush
    
  • 测试链接有效性:触发一次密码重置流程,检查邮件中的链接是否正确包含Token参数,且能正常访问你的外部重置页面。
  • 特殊字符处理:如果Token包含特殊字符,可使用url_encode函数确保参数传递安全:
    <a href="https://www.my-simple.com/reset-password/?token={{var url_encode($customer.rp_token)}}" target="_blank">{{trans "Set a New Password"}}</a>
    

内容的提问来源于stack exchange,提问作者Elpop

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 01:12:26