import { useState, useEffect } from 'react' export default function EmailSettings() { const [status, setStatus] = useState(null) const [testTo, setTestTo] = useState('') const [testing, setTesting] = useState(false) const [testMsg, setTestMsg] = useState(null) useEffect(()=>{ const token = localStorage.getItem('bodytrack_token')||'' fetch('/api/admin/email/status',{headers:{'X-Auth-Token':token}}) .then(r=>r.json()).then(setStatus) },[]) const sendTest = async () => { if (!testTo) return setTesting(true); setTestMsg(null) try { const token = localStorage.getItem('bodytrack_token')||'' const r = await fetch('/api/admin/email/test',{ method:'POST',headers:{'Content-Type':'application/json','X-Auth-Token':token}, body:JSON.stringify({to:testTo}) }) if(!r.ok) throw new Error((await r.json()).detail) setTestMsg('✓ Test-E-Mail gesendet!') } catch(e){ setTestMsg('✗ Fehler: '+e.message) } finally{ setTesting(false) } } return (
.env Datei setzen.>}
.env Datei hinzu:
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=deine@gmail.com
SMTP_PASS=dein_app_passwort
APP_URL=http://192.168.2.49:3002