32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
|
//import * as nodemailer from "nodemailer";
|
||
|
|
||
|
//const nodemailer = require('lib/nodemailer');
|
||
|
//const nodemailer = require('node_modules/nodemailer/lib/nodemailer');
|
||
|
const nodemailer = require('nodemailer');
|
||
|
|
||
|
// Erstelle den Transporter
|
||
|
const transporter = nodemailer.createTransport({
|
||
|
//host: "localhost", // MailHog läuft standardmäßig auf localhost
|
||
|
host: "mailhog.mailhog.svc.cluster.local", //"10.96.177.226", // MailHog ClusterIP
|
||
|
port: 1025, // Standard-MailHog SMTP-Port
|
||
|
secure: false // MailHog benötigt keine Verschlüsselung
|
||
|
});
|
||
|
|
||
|
// E-Mail senden
|
||
|
async function sendEmail() {
|
||
|
try {
|
||
|
const info = await transporter.sendMail({
|
||
|
from: '"Test Sender" <test@example.com>',
|
||
|
to: "Christopher.Hase@telekom.com;test@mailhog.local",
|
||
|
subject: "Hallo von MailHog",
|
||
|
text: "Das ist eine Test-E-Mail mit MailHog und TypeScript.",
|
||
|
html: "<p>Das ist eine <b>Test-E-Mail</b> mit MailHog und TypeScript.</p>"
|
||
|
});
|
||
|
|
||
|
console.log("E-Mail gesendet: ", info.messageId);
|
||
|
} catch (error) {
|
||
|
console.error("Fehler beim Senden der E-Mail:", error);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
sendEmail();
|