2025-03-25 08:54:22 +00:00
|
|
|
import { exec } from 'child_process';
|
|
|
|
|
2025-03-25 11:39:58 +00:00
|
|
|
const nodemailer = require('nodemailer');
|
|
|
|
|
2025-03-25 08:54:22 +00:00
|
|
|
exec('iching divine', (error, stdout, stderr) => {
|
|
|
|
|
2025-03-25 14:04:48 +00:00
|
|
|
console.log(`Begin`);
|
2025-03-25 08:54:22 +00:00
|
|
|
|
|
|
|
if (error) {
|
2025-03-25 14:04:48 +00:00
|
|
|
console.error(`Error: ${error.message}`);
|
2025-03-25 08:54:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (stderr) {
|
|
|
|
console.error(`Stderr: ${stderr}`);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2025-03-25 11:39:58 +00:00
|
|
|
//console.log(`Ergebnis:\n${stdout}`);
|
2025-03-25 08:54:22 +00:00
|
|
|
|
2025-03-25 14:04:48 +00:00
|
|
|
console.log(`Send E-Mail`);
|
|
|
|
|
2025-03-25 11:39:58 +00:00
|
|
|
sendEmail(stdout); //TODO: param
|
2025-03-25 08:54:22 +00:00
|
|
|
});
|
2025-03-25 11:39:58 +00:00
|
|
|
|
|
|
|
// 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
|
2025-03-25 14:04:48 +00:00
|
|
|
});
|
2025-03-25 11:39:58 +00:00
|
|
|
|
|
|
|
// 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",
|
2025-03-25 11:53:25 +00:00
|
|
|
subject: "Horoscope from MailHog",
|
2025-03-25 11:39:58 +00:00
|
|
|
text: content,
|
|
|
|
html: "<p> ${content} </p>"
|
|
|
|
});
|
|
|
|
|
2025-03-25 14:04:48 +00:00
|
|
|
console.log("E-Mail sent: ", info.messageId);
|
2025-03-25 11:39:58 +00:00
|
|
|
} catch (error) {
|
2025-03-25 14:04:48 +00:00
|
|
|
console.error("Error Sending E-Mail:", error);
|
2025-03-25 11:39:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|