-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
71 lines (63 loc) · 1.59 KB
/
index.ts
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import nodemailer from "nodemailer";
import axios from "axios";
import { config } from "./config";
import figlet from "figlet";
let counter: number = 0;
console.log(`
${figlet.textSync("Catmail", {
font: "Standard",
horizontalLayout: "default",
verticalLayout: "default",
width: 80,
whitespaceBreak: true,
})}
________________________________________
Catmail Starting -- Sending ${config.total_emails} cats to ${config.send_to}.
----------------------------------------
`);
const catmail = nodemailer.createTransport({
host: config.server.hostname,
port: config.server.port,
secure: config.server.tls,
auth: {
user: config.server.user,
pass: config.server.pass,
},
tls: {
rejectUnauthorized: false,
},
});
async function sendCatz() {
try {
let {
data: { file: catImageUrl },
} = await axios.get("https://aws.random.cat/meow");
let { data: catImage } = await axios.get(catImageUrl, {
responseType: "arraybuffer",
});
let body = {
from: config.server.user,
to: config.send_to,
subject: `cat ${counter + 1} !!!`,
html: `<p> Someone wants you to have many cat pictures my friend. Here is cat #${
counter + 1
}!!! </p>`,
attachments: [
{
filename: `cat-${counter + 1}.jpg`,
content: catImage,
},
],
};
await catmail.sendMail(body);
console.log(`cat ${counter + 1} sent via catmail!!!`);
counter++;
} catch (error) {
return console.error(error);
}
}
(async () => {
for await (const _ of Array(config.total_emails)) {
await sendCatz();
}
})();