Skip to content

Instantly share code, notes, and snippets.

@frkr
Created April 12, 2024 23:50
Show Gist options
  • Save frkr/5f6d6f7aea89feab73c69fb725b1ec99 to your computer and use it in GitHub Desktop.
Save frkr/5f6d6f7aea89feab73c69fb725b1ec99 to your computer and use it in GitHub Desktop.
RClone check files and sendmail with SMTP
#!/usr/bin/env -S deno run --allow-net
console.log("rclone lsjson r2: --files-only --recursive | ./sendjson.ts");
import {readLines} from "https://deno.land/std@0.222.1/io/mod.ts";
import {SMTPClient} from "https://deno.land/x/denomailer/mod.ts";
const inputer = [];
for await (const l of readLines(Deno.stdin)) {
inputer.push(l);
}
const jsonInput = JSON.parse(inputer.join(""));
const msgs: string[] = [];
jsonInput.forEach((item: any) => {
if (new Date(item.ModTime).getTime() > new Date("2020-09-10").getTime()) {
msgs.push(item.Name);
}
})
console.log(msgs);
const client = new SMTPClient({
connection: {
hostname: "smtps.uhserver.com",
port: 465,
tls: true,
auth: {
username: "davi.mesquita@taking.com.br",
password: "",
},
},
});
await client.send({
from: "davi.mesquita@taking.com.br",
to: "davimesquita@gmail.com",
subject: "example",
content: "auto",
html: msgs.join("\n"),
});
await client.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment