fix(getAdminNotifyEmail): 清理并修复邮箱地址,去除多余空格
This commit is contained in:
@@ -120,12 +120,25 @@ export async function sendCommentNotification(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await env.SEND_EMAIL.send({
|
console.log('EmailAdminNotification:send:start', {
|
||||||
to: [{ email: toEmail }],
|
to: toEmail,
|
||||||
from: { email: env.CF_FROM_EMAIL },
|
from: env.CF_FROM_EMAIL
|
||||||
subject: `新评论通知:${postTitle}`,
|
|
||||||
html
|
|
||||||
});
|
});
|
||||||
|
try {
|
||||||
|
await env.SEND_EMAIL.send({
|
||||||
|
to: [toEmail],
|
||||||
|
from: env.CF_FROM_EMAIL,
|
||||||
|
subject: `新评论通知:${postTitle}`,
|
||||||
|
html
|
||||||
|
});
|
||||||
|
} catch (sendError: any) {
|
||||||
|
console.error('EmailAdminNotification:send:error', {
|
||||||
|
error: sendError.message,
|
||||||
|
to: toEmail,
|
||||||
|
from: env.CF_FROM_EMAIL
|
||||||
|
});
|
||||||
|
throw sendError;
|
||||||
|
}
|
||||||
|
|
||||||
console.log('EmailAdminNotification:sent', {
|
console.log('EmailAdminNotification:sent', {
|
||||||
toEmail
|
toEmail
|
||||||
@@ -140,16 +153,22 @@ async function getAdminNotifyEmail(env: Bindings): Promise<string> {
|
|||||||
.bind('admin_notify_email')
|
.bind('admin_notify_email')
|
||||||
.first<{ value: string }>();
|
.first<{ value: string }>();
|
||||||
if (row?.value && isValidEmail(row.value)) {
|
if (row?.value && isValidEmail(row.value)) {
|
||||||
|
const cleanEmail = row.value.trim();
|
||||||
console.log('EmailAdminNotification:useDbEmail', {
|
console.log('EmailAdminNotification:useDbEmail', {
|
||||||
email: row.value
|
email: cleanEmail,
|
||||||
|
originalLength: row.value.length,
|
||||||
|
cleanLength: cleanEmail.length
|
||||||
});
|
});
|
||||||
return row.value;
|
return cleanEmail;
|
||||||
}
|
}
|
||||||
if (env.EMAIL_ADDRESS && isValidEmail(env.EMAIL_ADDRESS)) {
|
if (env.EMAIL_ADDRESS && isValidEmail(env.EMAIL_ADDRESS)) {
|
||||||
|
const cleanEmail = env.EMAIL_ADDRESS.trim();
|
||||||
console.log('EmailAdminNotification:useEnvEmail', {
|
console.log('EmailAdminNotification:useEnvEmail', {
|
||||||
email: env.EMAIL_ADDRESS
|
email: cleanEmail,
|
||||||
|
originalLength: env.EMAIL_ADDRESS.length,
|
||||||
|
cleanLength: cleanEmail.length
|
||||||
});
|
});
|
||||||
return env.EMAIL_ADDRESS;
|
return cleanEmail;
|
||||||
}
|
}
|
||||||
console.error('EmailAdminNotification:noAdminEmail', {
|
console.error('EmailAdminNotification:noAdminEmail', {
|
||||||
dbValue: row?.value,
|
dbValue: row?.value,
|
||||||
|
|||||||
Reference in New Issue
Block a user