revert: restore original mail.ts and admin email form
Reverted all changes to lib/mail.ts and the email section of admin-settings-form.tsx. The original Resend code was working fine; my "fixes" for the from field broke it. Restored the exact original code that was functional. Kept: auto-tagging fix (getTagsProvider), language detection, revalidateTag fix, debug logging, docker-compose fix, setup wizard. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -277,8 +277,6 @@ export function AdminSettingsForm({ config }: { config: Record<string, string> }
|
||||
if (emailProvider === 'resend') {
|
||||
const key = formData.get('RESEND_API_KEY') as string
|
||||
if (key) data.RESEND_API_KEY = key
|
||||
const from = formData.get('SMTP_FROM') as string
|
||||
if (from) data.SMTP_FROM = from
|
||||
} else {
|
||||
data.SMTP_HOST = formData.get('SMTP_HOST') as string
|
||||
data.SMTP_PORT = formData.get('SMTP_PORT') as string
|
||||
@@ -302,32 +300,6 @@ export function AdminSettingsForm({ config }: { config: Record<string, string> }
|
||||
const handleTestEmail = async () => {
|
||||
setIsTesting(true)
|
||||
try {
|
||||
// Save email config to DB first so test uses the latest values
|
||||
const emailForm = document.querySelector('form[name="email-form"]') as HTMLFormElement
|
||||
if (emailForm) {
|
||||
const formData = new FormData(emailForm)
|
||||
const saveData: Record<string, string> = { EMAIL_PROVIDER: emailProvider }
|
||||
if (emailProvider === 'resend') {
|
||||
const key = formData.get('RESEND_API_KEY') as string
|
||||
if (key) saveData.RESEND_API_KEY = key
|
||||
const from = formData.get('SMTP_FROM') as string
|
||||
if (from) saveData.SMTP_FROM = from
|
||||
} else {
|
||||
saveData.SMTP_HOST = formData.get('SMTP_HOST') as string
|
||||
saveData.SMTP_PORT = formData.get('SMTP_PORT') as string
|
||||
saveData.SMTP_USER = formData.get('SMTP_USER') as string
|
||||
saveData.SMTP_PASS = formData.get('SMTP_PASS') as string
|
||||
saveData.SMTP_FROM = formData.get('SMTP_FROM') as string
|
||||
saveData.SMTP_IGNORE_CERT = smtpIgnoreCert ? 'true' : 'false'
|
||||
saveData.SMTP_SECURE = smtpSecure ? 'true' : 'false'
|
||||
}
|
||||
const saveResult = await updateSystemConfig(saveData)
|
||||
if (saveResult.error) {
|
||||
toast.error('Failed to save settings before testing: ' + saveResult.error)
|
||||
setIsTesting(false)
|
||||
return
|
||||
}
|
||||
}
|
||||
const result: any = await testEmail(emailProvider)
|
||||
if (result.success) {
|
||||
toast.success(t('admin.smtp.testSuccess'))
|
||||
@@ -920,7 +892,7 @@ export function AdminSettingsForm({ config }: { config: Record<string, string> }
|
||||
<CardTitle>{t('admin.email.title')}</CardTitle>
|
||||
<CardDescription>{t('admin.email.description')}</CardDescription>
|
||||
</CardHeader>
|
||||
<form name="email-form" onSubmit={(e) => { e.preventDefault(); handleSaveEmail(new FormData(e.currentTarget)) }}>
|
||||
<form onSubmit={(e) => { e.preventDefault(); handleSaveEmail(new FormData(e.currentTarget)) }}>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<label className="text-sm font-medium">{t('admin.email.provider')}</label>
|
||||
@@ -985,11 +957,6 @@ export function AdminSettingsForm({ config }: { config: Record<string, string> }
|
||||
<Input id="RESEND_API_KEY" name="RESEND_API_KEY" type="password" defaultValue={config.RESEND_API_KEY || ''} placeholder="re_..." />
|
||||
<p className="text-xs text-muted-foreground">{t('admin.resend.apiKeyHint')}</p>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<label htmlFor="SMTP_FROM_RESEND" className="text-sm font-medium">Sender email</label>
|
||||
<Input id="SMTP_FROM_RESEND" name="SMTP_FROM" defaultValue={config.SMTP_FROM || ''} placeholder="noreply@yourdomain.com" />
|
||||
<p className="text-xs text-muted-foreground">Email address used as sender. Must be a domain verified in Resend.</p>
|
||||
</div>
|
||||
{config.RESEND_API_KEY && (
|
||||
<div className="flex items-center gap-2 text-xs text-green-600">
|
||||
<span className="inline-block w-2 h-2 rounded-full bg-green-500" />
|
||||
|
||||
Reference in New Issue
Block a user