import nodemailer from "nodemailer"; import dotenv from "dotenv"; dotenv.config(); export function sendMail(username, message) { const transporter = nodemailer.createTransport({ host: process.env.MAIL_HOST, port: process.env.MAIL_PORT, secure: true, auth: { user: process.env.MAIL_USER, pass: process.env.MAIL_PASSWORD, }, }); (async () => { const mailText = `Neue Kontaktanfrage im Ausleihsystem.\n\nBenutzername: ${username}\n\nNachricht:\n${message}`; const mailHtml = ` Neue Nachricht im Ausleihsystem

Neue Nachricht im Ausleihsystem

Benutzername: ${username}

Nachricht:

${message}

`; const info = await transporter.sendMail({ from: '"Ausleihsystem" ', to: process.env.MAIL_SENDEES_CONTACT, subject: "Sie haben eine neue Nachricht!", text: mailText, html: mailHtml, }); console.log("Contact message sent: %s", info.messageId); })(); }