实际上我正在尝试使用 ZeptoMail 发送电子邮件。 我创建了一个模板。
即
<html>
<body>{{name}}</body>
</html>
我正在使用 zepto 电子邮件发送 api 。
const axios = require('axios');
let data = JSON.stringify({
"from": {
"address": "abc@abc.com",
"name": "Paula"
},
"to": [
{
"email_address": {
"address": "abc@abc.com",
"name": "Abc"
}
}
],
"subject": "Hi",
"template_key": "my_template_key"
});
let config = {
method: 'post',
url: 'https://api.zeptomail.com/v1.1/email/template',
headers: {
'Authorization': 'my_token',
'Content-Type': 'application/json',
},
data : data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
但还需要发送“名称”,它在我的模板中充当变量。 我该如何发送。
您可以在请求正文中使用
"merge_info"
键。
在此键下添加所有变量。
参考:API文档
示例:
let data = JSON.stringify({
"from": {
"address": "abc@abc.com",
"name": "Paula"
},
"to": [
{
"email_address": {
"address": "abc@abc.com",
"name": "Abc"
}
}
],
"subject": "Hi",
"template_key": "my_template_key",
"merge_info": {
"name": "Guest",
...other_variables_here
}
});