Best Free Email Marketing Services
Email marketing is a powerful tool for connecting with customers and driving growth. One of its standout features is that you own the channel—unlike...
Email signature generators allow users to create professional email signatures through a web interface. This technical guide covers the implementation details, from front-end design to backend processing, including responsive HTML email templates and cross-client compatibility considerations.
Here are some templates.
// Core application structure
const EmailSignatureGenerator = {
components: {
formBuilder: FormBuilderComponent,
previewPane: PreviewComponent,
templateEngine: SignatureTemplateEngine,
exportManager: ExportManager
},
state: {
userData: {},
selectedTemplate: null,
currentPreview: null
}
};
class FormBuilderComponent {
constructor() {
this.fields = [
{
id: 'fullName',
type: 'text',
validation: /^[a-zA-Z\s]{2,50}$/,
required: true
},
{
id: 'jobTitle',
type: 'text',
validation: /^[a-zA-Z\s\-]{2,50}$/,
required: true
},
{
id: 'email',
type: 'email',
validation: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
required: true
},
{
id: 'phone',
type: 'tel',
validation: /^\+?[\d\s\-()]{10,20}$/,
required: false
},
{
id: 'companyLogo',
type: 'file',
accept: 'image/*',
maxSize: 500000, // 500KB
required: false
}
];
}
validateField(fieldId, value) {
const field = this.fields.find(f => f.id === fieldId);
return field.validation.test(value);
}
}
class SignatureTemplateEngine {
constructor() {
this.templates = {
modern: this.modernTemplate,
classic: this.classicTemplate,
minimal: this.minimalTemplate
};
}
modernTemplate(data) {
return `
<table cellpadding="0" cellspacing="0" style="font-family: Arial, sans-serif; color: #333333;">
<tr>
<td style="padding: 20px;">
<table cellpadding="0" cellspacing="0">
<tr>
<td style="vertical-align: top;">
${data.companyLogo ? `
<img src="${data.companyLogo}" alt="Company Logo" style="max-width: 100px; height: auto; margin-right: 20px;">
` : ''}
</td>
<td style="padding-left: ${data.companyLogo ? '20px' : '0'};">
<p style="margin: 0; font-size: 18px; font-weight: bold; color: #2c3e50;">
${data.fullName}
</p>
<p style="margin: 5px 0; font-size: 14px; color: #7f8c8d;">
${data.jobTitle}
</p>
<p style="margin: 5px 0; font-size: 14px;">
<a href="mailto:${data.email}" style="color: #3498db; text-decoration: none;">
${data.email}
</a>
</p>
${data.phone ? `
<p style="margin: 5px 0; font-size: 14px;">
<a href="tel:${data.phone}" style="color: #3498db; text-decoration: none;">
${data.phone}
</a>
</p>
` : ''}
</td>
</tr>
</table>
</td>
</tr>
</table>
`;
}
}
class ExportManager {
constructor() {
this.exportFormats = ['html', 'outlook', 'gmail'];
}
generateHTML(signature) {
return `
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Email Signature</title>
</head>
<body>
${signature}
</body>
</html>
`;
}
generateOutlookInstructions(signature) {
return {
signature: signature,
steps: [
"Open Outlook",
"Go to File > Options > Mail > Signatures",
"Click 'New' and name your signature",
"Paste the copied signature",
"Click 'OK' to save"
]
};
}
copyToClipboard(signature) {
// Implementation using Clipboard API
if (navigator.clipboard) {
return navigator.clipboard.writeText(signature);
}
// Fallback for older browsers
const textarea = document.createElement('textarea');
textarea.value = signature;
document.body.appendChild(textarea);
textarea.select();
document.execCommand('copy');
document.body.removeChild(textarea);
}
}
It's important that your systems play nice.
<table cellpadding="0" cellspacing="0" border="0" style="width: 100%;">
<tr>
<td style="padding: 0;">
<!-- Content here -->
</td>
</tr>
</table>
function inlineStyles(html) {
// Replace class-based styles with inline styles
const styleMap = {
'.signature-name': 'font-size: 18px; font-weight: bold; color: #2c3e50;',
'.signature-title': 'font-size: 14px; color: #7f8c8d;'
};
Object.entries(styleMap).forEach(([selector, styles]) => {
html = html.replace(
new RegExp(`class="${selector.substring(1)}"`, 'g'),
`style="${styles}"`
);
});
return html;
}
class ImageProcessor {
constructor() {
this.maxWidth = 300;
this.maxHeight = 100;
this.acceptedFormats = ['image/jpeg', 'image/png', 'image/gif'];
}
async processImage(file) {
if (!this.acceptedFormats.includes(file.type)) {
throw new Error('Unsupported image format');
}
const image = await this.loadImage(file);
const resized = this.resizeImage(image);
return this.convertToBase64(resized);
}
resizeImage(image) {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
let width = image.width;
let height = image.height;
if (width > this.maxWidth) {
height = (height * this.maxWidth) / width;
width = this.maxWidth;
}
if (height > this.maxHeight) {
width = (width * this.maxHeight) / height;
height = this.maxHeight;
}
canvas.width = width;
canvas.height = height;
ctx.drawImage(image, 0, 0, width, height);
return canvas;
}
}
Then, of course, you want to make sure you're crossing your Ts.
class SecurityManager {
constructor() {
this.allowedTags = ['p', 'br', 'b', 'i', 'a', 'img'];
this.allowedAttributes = {
'a': ['href'],
'img': ['src', 'alt']
};
}
sanitizeInput(input) {
return DOMPurify.sanitize(input, {
ALLOWED_TAGS: this.allowedTags,
ALLOWED_ATTR: this.allowedAttributes
});
}
validateImageURL(url) {
const pattern = /^(https?:\/\/.*\.(?:png|jpg|jpeg|gif))$/i;
return pattern.test(url);
}
}
describe('EmailSignatureGenerator', () => {
let generator;
beforeEach(() => {
generator = new EmailSignatureGenerator();
});
test('validates email format', () => {
const validEmail = 'user@example.com';
const invalidEmail = 'invalid-email';
expect(generator.formBuilder.validateField('email', validEmail)).toBe(true);
expect(generator.formBuilder.validateField('email', invalidEmail)).toBe(false);
});
test('generates signature HTML', () => {
const userData = {
fullName: 'John Doe',
jobTitle: 'Senior Developer',
email: 'john@example.com'
};
const signature = generator.templateEngine.modernTemplate(userData);
expect(signature).toContain(userData.fullName);
expect(signature).toContain(userData.jobTitle);
expect(signature).toContain(userData.email);
});
});
class PerformanceOptimizer {
constructor() {
this.cache = new Map();
this.debounceTimeout = null;
}
debouncePreview(callback, wait = 300) {
clearTimeout(this.debounceTimeout);
this.debounceTimeout = setTimeout(callback, wait);
}
cacheTemplate(templateId, data) {
const key = `${templateId}-${JSON.stringify(data)}`;
if (!this.cache.has(key)) {
this.cache.set(key, this.generateTemplate(templateId, data));
}
return this.cache.get(key);
}
clearCache() {
this.cache.clear();
}
}
This technical implementation provides a robust foundation for building an email signature generator that works across different email clients while maintaining good performance and security standards.
Email marketing is a powerful tool for connecting with customers and driving growth. One of its standout features is that you own the channel—unlike...
Unsubscribing from email lists has become a routine part of modern life. Whether you accidentally opt into marketing emails during a purchase or...
Zero-party data is a valuable type of information that consumers willingly and proactively share with brands. Unlike other data categories such as...