sendgrid - 如何计算 SendGrid 中每个个性化块的替换限制?
问题描述
我正在尝试使用事务模板通过 SendGrid 发送电子邮件,并看到替换受限的问题。
每个个性化块的替换限制为 10000 个字节。
我将通过从 SendGrid 获取模板并替换其中的所有占位符来解决此问题。但是我需要检查什么时候可以做到,我认为会检查有限的替换,我不知道 SendGrid 是如何计算的?也许替换中所有字符串的长度?
有什么帮助吗?
谢谢!
解决方案
我解决了我的问题并为关心的人分享了解决方案;)
解决方案:
您需要通过与 Sections 一起使用来优化 Substitutions
/**
* When you have the $variables too big, SendGrid will reject the message because
* SendGrid's Substitution is limited(10000 bytes)
*
* Before that, the format of substitution as below:
*
* {
* "to": [
* "example@example.com"
* ],
* "sub": {
* "%FirstName%": "This string maybe too long",
* "%LastName%": "This string maybe too long",
* ....
* ....
* more and limited
* }
* }
*
* To resolved this problem we will use the Section with Substitution as below:
*
* {
* "to": [
* "example@example.com"
* ],
* "sub": {
* "%FirstName%": "%FirstName%",
* "%LastName%": "%LastName%",
* ....
* ....
* more and more
* },
* "section": {
* "%FirstName%": "This string maybe too long",
* "%LastName%": "This string maybe too long",
* ....
* ....
* }
* }
*
* We will optimize the strings in Substitutions and let Section in SendGrid to contain that strings.
*/
推荐阅读
- python - 如何在两个列表之间找到完美匹配?
- docker - 从docker中的docker进行卷绑定安装?
- ios - 使用 Timer 的参考周期中的强、弱或无主
- generated - 如何生成正方形的多米诺骨牌?
- python - 如何将两个图像重叠在一起,创建图例并在 Python(Matplotlib)中保留 CRS?
- sql-server-2008 - 如何在 SQL Server 中进行松散字符搜索?
- ios - 如何在 TabBarController 加载它的视图后添加另一个 TabBarItem
- string - 有没有办法将字符串转换为 matlab GUI 中的函数调用?
- windows - 在 Windows 中运行脚本
- xamarin - 如何使用 applicatoin 中的日历控件在 Xamarin.Forms 中添加活动(约会、任务)?