Gmail 电子邮件模板中的转义字符
我有一个电子邮件模板,其中包含临时密码的var-Gmail 电子邮件模板中的转义字符,gmail,escaping,email-templates,Gmail,Escaping,Email Templates,我有一个电子邮件模板,其中包含临时密码的var-${token}。在这种情况下,令牌==@.iJ您将根据MDN文档进行转义: && “” Gmail认为是正确的,有没有一种方法可以在模板中做到这一点,即在模板中的${token}中添加某种过滤器?也许。你没有提到你使用的模板。谢谢,我添加了电子邮件模板。那是什么语言?它看起来像是使用${value}在模板文本中插入JavaScript字符串。 From: info@mycompany.com Subject: New User Act
${token}
。在这种情况下,令牌==@.iJ您将根据MDN文档进行转义:
&
&代码>
“
”
Gmail认为是正确的,有没有一种方法可以在模板中做到这一点,即在模板中的${token}中添加某种过滤器?也许。你没有提到你使用的模板。谢谢,我添加了电子邮件模板。那是什么语言?它看起来像是使用${value}
在模板文本中插入JavaScript字符串。
From: info@mycompany.com
Subject: New User Activation
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="alternative_boundary"
This is a message with multiple parts in MIME format.
--alternative_boundary
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Dear ${firstName} ${lastName},
Please click on the below link and use Temporary password: ${token} to activate your new account.
${reset_url}
--alternative_boundary
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>New account activation</title>
</head>
<body>
<p>Dear ${firstName} ${lastName},</p>
<p>Please click <a href="${reset_url}">here</a> to activate your new account and use verification code: ${token} in the page</p>
</body>
</html>
function escapeHtmlEntities(str) {
return str
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"');
}
...${escapeHtmlEntities(token)}...