export async function newsly2(e: {
from: string;
to: string[];
subject: string;
text: string;
html: string;
}) {
console.log("email:", JSON.stringify(e));
const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
const KEY = new URL(import.meta.url).pathname.split("/").at(-1);
await sqlite.execute(`
CREATE TABLE IF NOT EXISTS ${KEY}_newslies (
id INTEGER PRIMARY KEY AUTOINCREMENT,
from_email TEXT NOT NULL,
to_emails TEXT NOT NULL,
subject TEXT NOT NULL,
text_content TEXT NOT NULL,
html_content TEXT NOT NULL,
sent_at DATETIME DEFAULT CURRENT_TIMESTAMP
)
`);
await sqlite.execute(`
INSERT INTO ${KEY}_newslies (from_email, to_emails, subject, text_content, html_content)
VALUES (?, ?, ?, ?, ?)
`, [e.from, JSON.stringify(e.to), e.subject, e.text, e.html]);
}
const css = `
body {
font-family: Arial, sans-serif;
line-height: 1.6;
color: #333;
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
h1 {
color: #2c3e50;
}
p {
margin-bottom: 10px;
}
a {
color: #3498db;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
`;