Newsletter comming soon
This commit is contained in:
177
src/lib/email.ts
177
src/lib/email.ts
@@ -103,3 +103,180 @@ export async function sendPasswordResetEmail(email: string, resetToken: string)
|
||||
throw new Error('Failed to send password reset email');
|
||||
}
|
||||
}
|
||||
|
||||
export async function sendNewsletterWelcomeEmail(email: string) {
|
||||
try {
|
||||
await resend.emails.send({
|
||||
from: 'QR Master <onboarding@resend.dev>',
|
||||
replyTo: 'support@qrmaster.net',
|
||||
to: email,
|
||||
subject: '🎉 You\'re on the list! AI-Powered QR Features Coming Soon',
|
||||
html: `
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Welcome to QR Master AI Newsletter</title>
|
||||
</head>
|
||||
<body style="margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #f4f4f4;">
|
||||
<table width="100%" cellpadding="0" cellspacing="0" style="background-color: #f4f4f4; padding: 20px 0;">
|
||||
<tr>
|
||||
<td align="center">
|
||||
<table width="600" cellpadding="0" cellspacing="0" style="background-color: #ffffff; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
|
||||
<!-- Header -->
|
||||
<tr>
|
||||
<td style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); padding: 40px 30px; text-align: center;">
|
||||
<h1 style="margin: 0; color: #ffffff; font-size: 28px; font-weight: bold;">QR Master</h1>
|
||||
<p style="margin: 10px 0 0 0; color: #ffffff; font-size: 16px; opacity: 0.9;">AI-Powered QR Features</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Content -->
|
||||
<tr>
|
||||
<td style="padding: 40px 30px;">
|
||||
<h2 style="margin: 0 0 20px 0; color: #333333; font-size: 24px;">Welcome to the Future! 🚀</h2>
|
||||
|
||||
<p style="margin: 0 0 20px 0; color: #666666; font-size: 16px; line-height: 1.6;">
|
||||
Thank you for signing up to be notified about our revolutionary AI-powered QR code features! You're among the first to know when these game-changing capabilities launch.
|
||||
</p>
|
||||
|
||||
<div style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%); border-left: 4px solid #667eea; padding: 20px; margin: 30px 0; border-radius: 4px;">
|
||||
<h3 style="margin: 0 0 15px 0; color: #667eea; font-size: 18px;">What's Coming:</h3>
|
||||
<ul style="margin: 0; padding-left: 20px; color: #666666; font-size: 15px; line-height: 1.8;">
|
||||
<li><strong>Smart QR Generation</strong> - AI-powered content optimization & intelligent design suggestions</li>
|
||||
<li><strong>Advanced Analytics</strong> - Scan predictions, anomaly detection & natural language queries</li>
|
||||
<li><strong>Smart Content Management</strong> - AI chatbot, auto-categorization & smart bulk generation</li>
|
||||
<li><strong>Creative & Marketing</strong> - AI-generated designs, copy generation & campaign optimization</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<p style="margin: 20px 0; color: #666666; font-size: 16px; line-height: 1.6;">
|
||||
We're working hard to bring these features to life and can't wait to share them with you. We'll send you an email as soon as they're ready to use!
|
||||
</p>
|
||||
|
||||
<p style="margin: 30px 0 0 0; color: #666666; font-size: 16px; line-height: 1.6;">
|
||||
In the meantime, feel free to explore our existing features at <a href="https://www.qrmaster.net" style="color: #667eea; text-decoration: none;">qrmaster.net</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Footer -->
|
||||
<tr>
|
||||
<td style="background-color: #f8f8f8; padding: 30px; text-align: center; border-top: 1px solid #eeeeee;">
|
||||
<p style="margin: 0 0 10px 0; color: #999999; font-size: 12px;">
|
||||
© 2025 QR Master. All rights reserved.
|
||||
</p>
|
||||
<p style="margin: 0; color: #999999; font-size: 12px;">
|
||||
You're receiving this email because you signed up for AI feature notifications.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
`,
|
||||
});
|
||||
|
||||
console.log('Newsletter welcome email sent successfully to:', email);
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error('Error sending newsletter welcome email:', error);
|
||||
throw new Error('Failed to send newsletter welcome email');
|
||||
}
|
||||
}
|
||||
|
||||
export async function sendAIFeatureLaunchEmail(email: string) {
|
||||
try {
|
||||
await resend.emails.send({
|
||||
from: 'QR Master <onboarding@resend.dev>',
|
||||
replyTo: 'support@qrmaster.net',
|
||||
to: email,
|
||||
subject: '🚀 AI-Powered Features Are Here! QR Master Gets Smarter',
|
||||
html: `
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>AI Features Launched!</title>
|
||||
</head>
|
||||
<body style="margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #f4f4f4;">
|
||||
<table width="100%" cellpadding="0" cellspacing="0" style="background-color: #f4f4f4; padding: 20px 0;">
|
||||
<tr>
|
||||
<td align="center">
|
||||
<table width="600" cellpadding="0" cellspacing="0" style="background-color: #ffffff; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
|
||||
<!-- Header -->
|
||||
<tr>
|
||||
<td style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); padding: 40px 30px; text-align: center;">
|
||||
<h1 style="margin: 0; color: #ffffff; font-size: 32px; font-weight: bold;">🚀 They're Here!</h1>
|
||||
<p style="margin: 10px 0 0 0; color: #ffffff; font-size: 18px; opacity: 0.95;">AI-Powered QR Features Are Live</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Content -->
|
||||
<tr>
|
||||
<td style="padding: 40px 30px;">
|
||||
<h2 style="margin: 0 0 20px 0; color: #333333; font-size: 24px;">The wait is over! ✨</h2>
|
||||
|
||||
<p style="margin: 0 0 20px 0; color: #666666; font-size: 16px; line-height: 1.6;">
|
||||
We're excited to announce that the AI-powered features you've been waiting for are now live on QR Master! Your QR code creation just got a whole lot smarter.
|
||||
</p>
|
||||
|
||||
<div style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%); border-left: 4px solid #667eea; padding: 20px; margin: 30px 0; border-radius: 4px;">
|
||||
<h3 style="margin: 0 0 15px 0; color: #667eea; font-size: 18px;">✨ What's New:</h3>
|
||||
<ul style="margin: 0; padding-left: 20px; color: #666666; font-size: 15px; line-height: 1.8;">
|
||||
<li><strong>Smart QR Generation</strong> - AI optimizes your content and suggests the best designs automatically</li>
|
||||
<li><strong>Advanced Analytics</strong> - Predictive insights and natural language queries for your scan data</li>
|
||||
<li><strong>Auto-Organization</strong> - Your QR codes get categorized and tagged automatically</li>
|
||||
<li><strong>AI Design Studio</strong> - Generate unique, custom QR code designs with AI</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- CTA Button -->
|
||||
<table width="100%" cellpadding="0" cellspacing="0" style="margin: 30px 0;">
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://www.qrmaster.net/create" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #ffffff; text-decoration: none; padding: 16px 40px; border-radius: 8px; font-size: 16px; font-weight: bold; display: inline-block;">
|
||||
Try AI Features Now
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p style="margin: 20px 0 0 0; color: #666666; font-size: 16px; line-height: 1.6;">
|
||||
Log in to your QR Master account and start exploring the new AI capabilities. We can't wait to see what you create!
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Footer -->
|
||||
<tr>
|
||||
<td style="background-color: #f8f8f8; padding: 30px; text-align: center; border-top: 1px solid #eeeeee;">
|
||||
<p style="margin: 0 0 10px 0; color: #999999; font-size: 12px;">
|
||||
© 2025 QR Master. All rights reserved.
|
||||
</p>
|
||||
<p style="margin: 0; color: #999999; font-size: 12px;">
|
||||
You received this email because you subscribed to AI feature notifications.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
`,
|
||||
});
|
||||
|
||||
console.log('AI feature launch email sent successfully to:', email);
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error('Error sending AI feature launch email:', error);
|
||||
throw new Error('Failed to send AI feature launch email');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,6 +212,14 @@ export const RateLimits = {
|
||||
windowSeconds: 60 * 60,
|
||||
},
|
||||
|
||||
// Newsletter endpoints
|
||||
// Newsletter subscribe: 5 per hour (prevent spam)
|
||||
NEWSLETTER_SUBSCRIBE: {
|
||||
name: 'newsletter-subscribe',
|
||||
maxRequests: 5,
|
||||
windowSeconds: 60 * 60,
|
||||
},
|
||||
|
||||
// General API: 100 requests per minute
|
||||
API: {
|
||||
name: 'api',
|
||||
|
||||
@@ -140,6 +140,18 @@ export const createCheckoutSchema = z.object({
|
||||
priceId: z.string().min(1, 'Price ID is required'),
|
||||
});
|
||||
|
||||
// ==========================================
|
||||
// Newsletter Schemas
|
||||
// ==========================================
|
||||
|
||||
export const newsletterSubscribeSchema = z.object({
|
||||
email: z.string()
|
||||
.email('Invalid email format')
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.max(255, 'Email must be less than 255 characters'),
|
||||
});
|
||||
|
||||
// ==========================================
|
||||
// Helper: Format Zod Errors
|
||||
// ==========================================
|
||||
|
||||
Reference in New Issue
Block a user