EmailOS Template Command Documentation
The mailos template command manages HTML email templates for styling outgoing emails with custom designs and branding.
Basic Usage
mailos templateOpens interactive template management interface with options to create, edit, preview, or list templates.
Command-Line Flags
Basic Options
| Flag | Short | Type | Default | Description | Example |
|---|---|---|---|---|---|
--account | string | Email account to use | mailos template --account value | ||
--content | string | HTML content for template | mailos template --content value | ||
--from | string | Email account to use (alias for --account) | mailos template --from value |
Advanced Options
| Flag | Short | Type | Default | Description | Example |
|---|---|---|---|---|---|
--copy | string | Copy from existing template name | mailos template --copy value | ||
--edit | bool | false | Open template in default HTML editor | mailos template --edit | |
--file | string | Read HTML content from file | mailos template --file value | ||
--image | string | Local image file to embed as base64 | mailos template --image value | ||
--name | string | Template name | mailos template --name value | ||
--open-browser | bool | false | Open template HTML file in browser | mailos template --open-browser | |
--remove | bool | false | Remove existing template | mailos template --remove | |
--template-dir | string | Set template directory for account | mailos template --template-dir value |
Interactive Template Management
Running mailos template without flags opens an interactive menu with three options:
1. Create/Edit Template
- Prompts for template name if not provided with
--name - Multi-line HTML input terminated by typing "END" on a new line
- Validates that template contains
placeholder - Optional preview before saving
- Saves to appropriate location (local or global)
2. Preview Existing Template
- Lists available templates if no name specified
- Loads template and opens preview in browser with sample content
- Replaces placeholders with preview data for visual testing
3. List Templates
- Shows all available templates from both local and global locations
- Displays template names and their file paths
Template System
Placeholder Variables
Templates support the following placeholders that are replaced when emails are sent:
- Email content (required)- Profile picture (optional)
Storage Locations
Templates are stored with priority order:
- Local project:
.email/templates/[name].html - Global user:
~/.email/templates/[name].html
Local templates take precedence over global ones with the same name.
Template Files
- Saved as HTML files with
.htmlextension - Named templates:
[name].html - Default template:
default.html
Quick Actions
View Template in Browser
mailos template --open-browserOpens your current default template HTML file directly in the browser for visual inspection. Useful for:
- Quick visual review of template design
- Testing template appearance without sending emails
- Debugging layout issues
Create Named Template
mailos template --name companyCreates or edits a template with the specified name.
Remove Template
mailos template --remove --name companyRemoves the specified template. If no name provided, removes "default" template.
Template Structure
Basic Template Example
<html>
<body style="font-family: Arial; padding: 20px;">
<div class="header">
{{PROFILE_IMAGE}}
<h1>My Company</h1>
</div>
<div class="content">
{{BODY}}
</div>
<div class="footer">
<p>© 2024 My Company</p>
</div>
</body>
</html>Professional Template Example
<!DOCTYPE html>
<html>
<head>
<style>
.email-container {
max-width: 600px;
margin: 0 auto;
font-family: Arial, sans-serif;
color: #333;
}
.header {
background: #2c3e50;
color: white;
padding: 20px;
text-align: center;
}
.content {
padding: 30px;
background: #ffffff;
}
.footer {
background: #ecf0f1;
padding: 20px;
text-align: center;
font-size: 12px;
}
</style>
</head>
<body>
<div class="email-container">
<div class="header">
<h1>Professional Email</h1>
</div>
<div class="content">
{{BODY}}
</div>
<div class="footer">
Contact information and unsubscribe links
</div>
</div>
</body>
</html>Minimal Template Example
<div style="max-width: 500px; margin: 20px auto; font-family: Georgia, serif;">
<div style="border-bottom: 2px solid #e0e0e0; padding-bottom: 10px; margin-bottom: 20px;">
{{PROFILE_IMAGE}}
<span style="margin-left: 10px; font-size: 18px;">Company Name</span>
</div>
<div style="line-height: 1.6;">
{{BODY}}
</div>
<div style="margin-top: 30px; padding-top: 20px; border-top: 1px solid #e0e0e0; font-size: 14px; color: #666;">
Best regards,<br>
Your Name
</div>
</div>Profile Images
Profile Image Handling
When placeholder is used:
- Images are base64-encoded and embedded directly in the email
- Supported formats: JPG, JPEG, PNG, GIF, WEBP
- Automatically styled with
max-width: 150px; border-radius: 50%; - If no profile image is configured, placeholder is removed
Profile Image Tag Output
The system generates HTML like:
<img src="data:image/jpeg;base64,[encoded-data]" alt="Profile" style="max-width: 150px; height: auto; border-radius: 50%;">Integration with Email System
Automatic Template Application
Templates are automatically applied when:
- Sending emails with
mailos sendcommand - Email body contains markdown or HTML content
- Template file exists for the specified name (default: "default")
Template Bypass
Templates are bypassed when:
- Using
--plainflag with send commands - No template file exists
- Template loading fails
Template Management Commands
List All Templates
mailos template
# Choose option 3: List templatesShows all available templates with their file paths.
Preview Template
mailos template
# Choose option 2: Preview existing templateOpens template in browser with sample content for visual testing.
Edit Existing Template
mailos template --name existing-template
# Choose option 1: Create/Edit templateLoads existing template for modification or creates new one if it doesn't exist.
Best Practices
Email Client Compatibility
- Use inline CSS for maximum compatibility
- Avoid JavaScript (not supported by most email clients)
- Test with multiple email clients (Gmail, Outlook, Apple Mail)
- Use table layouts for complex designs if needed
Performance and Size
- Keep total email size under 100KB
- Optimize images before base64 encoding
- Minimize CSS to reduce file size
- Avoid external dependencies
Accessibility
- Include alt text for images
- Use semantic HTML structure
- Ensure sufficient color contrast
- Test with screen readers
Mobile Optimization
- Use responsive design principles
- Test on mobile devices
- Ensure readable font sizes
- Make tap targets large enough
Troubleshooting
Template Not Applied
- Verify template file exists at expected location
- Check that template contains
placeholder - Ensure not using
--plainflag when sending - Validate HTML syntax
Images Not Showing
- Check that profile image file exists and is readable
- Verify image format is supported (JPG, PNG, GIF, WEBP)
- Ensure image file size is reasonable (under 1MB recommended)
Browser Preview Issues
- Check that default browser is configured
- Verify template file permissions
- Test opening file manually in browser
Template Saving Issues
- Ensure directory permissions allow file creation
- Check available disk space
- Verify file path is valid and accessible
Examples
Creating Company Template
mailos template --name company
# Paste your company HTML template
# Type "END" when finished
# Preview if desired
# Confirm saveQuick Browser Preview
mailos template --open-browserRemove Old Template
mailos template --remove --name old-templateList Available Templates
mailos template
# Choose option 3File Locations
Templates are stored in these locations based on your configuration:
- Local Project:
.email/templates/[name].html(if.emaildirectory exists) - Global User:
~/.email/templates/[name].html(default location)
The system automatically creates the necessary directories when saving templates.
