Email Template
Email Template Management
Email templates allow you to create reusable email content with dynamic variables that can be customized for each recipient.
Overview
The template system supports:
HTML and Text Content: Rich HTML emails with optional plain text fallbacks
Dynamic Variables: Personalize emails with user-specific data
Template Types: Organize templates by purpose (welcome, password_reset, etc.)
Active/Inactive Status: Control which templates are available for use
Creating Templates
Step 1: Access Template Manager
Navigate to Admin Dashboard → Settings → Email System
Click on the Templates tab
Click "New Template" button
Step 2: Configure Template Details
Template Type: A unique identifier for the template (e.g., welcome_email
, password_reset
)
Use lowercase with underscores
Must be unique across all templates
Used when calling the email service API
Subject: The email subject line
Can include variables using
{{variable_name}}
syntaxExample:
Welcome to {{dao_name}}, {{user_name}}!
Step 3: Create Email Content
HTML Content: The main email body with rich formatting
<h1>Welcome to Treem DAO, {{user_name}}!</h1>
<p>Thank you for joining our community. Your account has been successfully created.</p>
<p>You can now access your dashboard at: <a href="{{dashboard_url}}">{{dashboard_url}}</a></p>
<p>Best regards,<br>The Treem DAO Team</p>
Text Content (Optional): Plain text version for email clients that don't support HTML
Welcome to Treem DAO, {{user_name}}!
Thank you for joining our community. Your account has been successfully created.
You can now access your dashboard at: {{dashboard_url}}
Best regards,
The Treem DAO Team
Step 4: Define Variables
Variables: Comma-separated list of variables used in the template
Example:
user_name, dao_name, dashboard_url
Variables are automatically detected from your content
Used for validation when sending emails
Step 5: Set Status
Active: Enable or disable the template
Only active templates can be used for sending emails
Inactive templates are preserved but not available for selection
Template Variables
Common Variables
user_name
User's display name
John Doe
dao_name
DAO organization name
Treem DAO
dashboard_url
Link to user dashboard
https://app.treemdao.com/dashboard
confirm_url
Email confirmation link
https://app.treemdao.com/confirm?token=...
reset_url
Password reset link
https://app.treemdao.com/reset?token=...
Custom Variables
You can define custom variables for specific use cases:
proposal_title
- For governance notificationstransaction_amount
- For payment confirmationsevent_date
- For event remindersstake_amount
- For staking notifications
Template Types
System Templates
welcome_email: Sent when users first join the DAO
Variables:
user_name
,dao_name
,dashboard_url
password_reset: Sent when users request password reset
Variables:
user_name
,reset_url
,expiry_time
email_confirmation: Sent to verify email addresses
Variables:
user_name
,confirm_url
Governance Templates
new_proposal: Notify users about new proposals
Variables:
user_name
,proposal_title
,proposal_url
,voting_deadline
voting_reminder: Remind users to vote on active proposals
Variables:
user_name
,proposal_title
,days_remaining
,vote_url
Transaction Templates
purchase_confirmation: Confirm token purchases
Variables:
user_name
,token_amount
,total_cost
,transaction_id
staking_confirmation: Confirm staking transactions
Variables:
user_name
,stake_amount
,lock_period
,unlock_date
Managing Templates
Editing Templates
Click the Edit icon on any template
Modify the template content
Update variables if needed
Click "Update Template"
Previewing Templates
Click the Preview icon on any template
View the rendered HTML content
Check the plain text version
Review variable usage
Deleting Templates
Click the Delete icon on any template
Confirm the deletion
Warning: This action cannot be undone
Best Practices
Content Guidelines
Keep it concise: Users prefer shorter emails
Clear call-to-action: Make it obvious what users should do next
Mobile-friendly: Use responsive HTML design
Brand consistency: Match your DAO's visual identity
Variable Usage
Always provide fallbacks: Handle cases where variables might be empty
Validate variables: Ensure all template variables are provided when sending
Use descriptive names: Make variable purposes clear
Document custom variables: Keep track of what each variable represents
HTML Best Practices
Use table-based layouts: Better email client compatibility
Inline CSS: Many email clients strip external stylesheets
Test across clients: Email rendering varies significantly
Include alt text: For images and accessibility
Integration with Bulk Sending
Templates integrate seamlessly with the bulk email sender:
Select your template from the dropdown
Fill in the required variables
Choose your recipient groups
Send to multiple users at once
API Integration
Templates can be used programmatically via the enhanced-email-service:
const { data, error } = await supabase.functions.invoke('enhanced-email-service', {
body: {
template_type: 'welcome_email',
recipient_email: '[email protected]',
variables: {
user_name: 'John Doe',
dao_name: 'Treem DAO',
dashboard_url: 'https://app.treemdao.com/dashboard'
}
}
});
Troubleshooting
Template Not Available for Selection
Check if the template is marked as Active
Verify the template_type is unique
Ensure all required fields are filled
Variables Not Replacing
Check variable names match exactly (case-sensitive)
Ensure variables are defined in the template configuration
Verify variable syntax uses
{{variable_name}}
format
HTML Not Rendering
Test HTML in the preview function
Check for unclosed tags or invalid markup
Ensure proper email-safe HTML structure
Last updated
Was this helpful?