AI Newsletter Digest improvements: fixed QP soft line break decoding, URL extraction, and content cleaning
This commit is contained in:
45
archive/inactive-skills/agent-voice/lib/email.ts
Normal file
45
archive/inactive-skills/agent-voice/lib/email.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Email utility using AWS SES SMTP
|
||||
*/
|
||||
|
||||
import nodemailer from 'nodemailer';
|
||||
|
||||
// Create reusable transporter
|
||||
const transporter = nodemailer.createTransport({
|
||||
host: process.env.SMTP_HOST,
|
||||
port: parseInt(process.env.SMTP_PORT || '587'),
|
||||
secure: false, // Use STARTTLS
|
||||
auth: {
|
||||
user: process.env.SMTP_USERNAME,
|
||||
pass: process.env.SMTP_PASSWORD
|
||||
}
|
||||
});
|
||||
|
||||
interface EmailOptions {
|
||||
to: string;
|
||||
subject: string;
|
||||
html: string;
|
||||
from?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an email via AWS SES
|
||||
*/
|
||||
export async function sendEmail(options: EmailOptions) {
|
||||
const from = options.from || process.env.FROM_EMAIL || 'noreply@viralguru.app';
|
||||
|
||||
try {
|
||||
const info = await transporter.sendMail({
|
||||
from,
|
||||
to: options.to,
|
||||
subject: options.subject,
|
||||
html: options.html
|
||||
});
|
||||
|
||||
console.log('Email sent:', info.messageId);
|
||||
return { success: true, messageId: info.messageId };
|
||||
} catch (error) {
|
||||
console.error('Email send failed:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user