49 lines
No EOL
1.3 KiB
TypeScript
49 lines
No EOL
1.3 KiB
TypeScript
import { exec } from 'child_process';
|
|
|
|
const nodemailer = require('nodemailer');
|
|
|
|
exec('iching divine', (error, stdout, stderr) => {
|
|
|
|
console.log(`Beginn`);
|
|
|
|
|
|
if (error) {
|
|
console.error(`Fehler: ${error.message}`);
|
|
return;
|
|
}
|
|
|
|
if (stderr) {
|
|
console.error(`Stderr: ${stderr}`);
|
|
return;
|
|
}
|
|
|
|
//console.log(`Ergebnis:\n${stdout}`);
|
|
|
|
sendEmail(stdout); //TODO: param
|
|
});
|
|
|
|
// Erstelle den Transporter
|
|
const transporter = nodemailer.createTransport({
|
|
//host: "localhost", // MailHog läuft standardmäßig auf localhost
|
|
host: "mailhog.mailhog.svc.cluster.local", // MailHog ClusterIP
|
|
port: 1025, // Standard-MailHog SMTP-Port
|
|
secure: false // MailHog benötigt keine Verschlüsselung
|
|
});
|
|
|
|
// E-Mail senden
|
|
async function sendEmail(content: string) { //TODO: param
|
|
try {
|
|
const info = await transporter.sendMail({
|
|
from: '"Test Sender" <test@example.com>',
|
|
to: "Christopher.Hase@telekom.com;test@mailhog.local",
|
|
subject: "Horoscope from MailHog",
|
|
text: content,
|
|
html: "<p> ${content} </p>"
|
|
});
|
|
|
|
console.log("E-Mail gesendet: ", info.messageId);
|
|
} catch (error) {
|
|
console.error("Fehler beim Senden der E-Mail:", error);
|
|
}
|
|
}
|
|
|