When using SendCloud to configure an email template, you can include dynamic placeholders in your email content. These placeholders will be replaced with actual values when the email is sent.
Steps to Configure a SendCloud Email Template
1. Create or Edit a Template
- Log in to the SendCloud console.
- Navigate to Email Templates in the dashboard.
- Create a new template or edit an existing one.
2. Define Placeholders for Dynamic Data
In your email template, use SendCloud placeholders (in the format {{placeholder}}
) for the dynamic values you want to include. For example:
<div style="width: 80%; max-width: 50em; margin: 4em auto; padding: 3em 2em; border-radius: .5em; background-color: #fff; box-shadow: 0 .5em 4em rgba(0,0,0,.1); line-height: 1.5;"> <div style="font-size: 1.2em; font-weight: bold;">尊敬的客户,您好!</div> <p>您的企业{{companyName}}已创建成功,您可以使用</p> <ul> <li>邮箱:<span>{{mail}}</span></li> <li>密码:<span>{{code}}</span></li> </ul> <p>登录 <a href="https://XXX?mail={{mail}}&code={{code}}">XXX</a> 查看详情。</p> </div>
3. Save and Publish the Template
- Save the template.
- Test the template by sending a sample email to verify that placeholders are replaced correctly.
4. Use the Template in API Calls
When sending an email using the SendCloud API, include the placeholders' values in the request payload.
Example Request Payload
{ "apiUser": "your_api_user", "apiKey": "your_api_key", "from": "your_email@example.com", "to": "recipient_email@example.com", "templateInvokeName": "your_template_name", "substitutionVars": { "to": ["recipient_email@example.com"], "sub": { "%companyName%": ["Your Company Name"], "%mail%": ["recipient@example.com"], "%code%": ["123456"] } } }
Key Notes
- Template Placeholder Syntax: Use
{{placeholder}}
in your template, but when sending via API, map{{placeholder}}
to corresponding keys in thesubstitutionVars
field. - Testing: Always test your template before sending bulk emails to ensure placeholders are replaced correctly.
- Dynamic URLs: The placeholders in URLs (e.g.,
{{mail}}
,{{code}}
) will be substituted with actual values provided in the API call.
By following these steps, you can successfully configure and send dynamic emails using SendCloud. Let me know if you need further assistance!