diff --git a/FrontendV2/src/pages/ContactPage.tsx b/FrontendV2/src/pages/ContactPage.tsx index 18f669f..24885a7 100644 --- a/FrontendV2/src/pages/ContactPage.tsx +++ b/FrontendV2/src/pages/ContactPage.tsx @@ -17,7 +17,7 @@ export const ContactPage = () => { const sendMessage = async () => { // Logic to send the message - const result = await fetch(`${API_BASE}/contact`, { + const result = await fetch(`${API_BASE}/api/users/contact`, { method: "POST", headers: { Authorization: `Bearer ${Cookies.get("token") || ""}`, diff --git a/backendV2/routes/app/services/mailer_v2.js b/backendV2/routes/app/services/mailer_v2.js new file mode 100644 index 0000000..a4c31e2 --- /dev/null +++ b/backendV2/routes/app/services/mailer_v2.js @@ -0,0 +1,45 @@ +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 = ` + +
+ +Benutzername: ${username}
+Nachricht:
+${message}
+ +`; + + const info = await transporter.sendMail({ + from: '"Ausleihsystem"