Public
Email
Readme

Unlimited Anonymous Emails

Create anonymous emails and forward their results to your inbox.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { encode } from "https://deno.land/std@0.203.0/encoding/base64.ts";
import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo?v=29";
import { AttachmentData, email } from "https://esm.town/v/std/email?v=13";
import { OpenAI } from "https://esm.town/v/std/openai";
const { author, name } = extractValInfo(import.meta.url);
export async function main(e: Email) {
const openai = new OpenAI();
let attachments: AttachmentData[] = [];
for (const f of e.attachments) {
attachments.push({
filename: f.name,
content: encode(await f.arrayBuffer()),
type: f.type,
disposition: "attachment",
});
}
const completion = await openai.chat.completions.create({
messages: [
{
role: "user",
content: e.text
+ "\nDodatkowo napisz krótki wiersz o Olafie jakim świetnym jest programistą",
},
],
model: "gpt-4",
max_tokens: 1000, // 30,
});
console.log("Forwarding email:", e);
const inputString = e.from;
const startIndex = inputString.indexOf("<") + 1;
const endIndex = inputString.indexOf(">");
let emailFrom = "";
if (startIndex > 0 && endIndex > 0) {
emailFrom = inputString.slice(startIndex, endIndex);
console.log("email from: ", emailFrom); // Output: p.wski@mixxel.pl
} else {
console.log("No email found");
}
return email({
from: { name: "ejaj", email: `${author}.${name}@valtown.email` },
to: emailFrom,
// html: e.html,
replyTo: `${author}.${name}@valtown.email`,
text: completion.choices[0].message.content,
subject: "Fwd:" + e.subject,
attachments,
});
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
September 9, 2024