fix: allow email inbox setup from SMTP env without old mail config
This commit is contained in:
@@ -78,7 +78,17 @@ const data = (j) => (j && j.data !== undefined ? j.data : j);
|
||||
|
||||
async function main() {
|
||||
const env = loadEnv(path.join(ROOT, '.env'));
|
||||
const old = JSON.parse(fs.readFileSync(OLD_MAIL_CFG, 'utf8'));
|
||||
const old = fs.existsSync(OLD_MAIL_CFG)
|
||||
? JSON.parse(fs.readFileSync(OLD_MAIL_CFG, 'utf8'))
|
||||
: {
|
||||
imap: { auth: { user: env.SMTP_USER, pass: env.SMTP_PASS } },
|
||||
smtp: {
|
||||
host: env.SMTP_HOST || 'smtp.163.com',
|
||||
port: Number(env.SMTP_PORT || 465),
|
||||
auth: { user: env.SMTP_USER, pass: env.SMTP_PASS },
|
||||
},
|
||||
};
|
||||
if (!old.imap?.auth?.user || !old.imap?.auth?.pass) throw new Error('缺少 IMAP/SMTP 凭据(设置 SMTP_USER/SMTP_PASS 或提供旧 mail.config.json)');
|
||||
const base = (env.LIBREDESK_BASE_URL || 'http://localhost:9000').replace(/\/+$/, '');
|
||||
const c = createClient(base);
|
||||
await c.post('/api/v1/auth/login', { email: env.LIBREDESK_SYSTEM_EMAIL || 'System', password: env.LIBREDESK_SYSTEM_USER_PASSWORD });
|
||||
|
||||
Reference in New Issue
Block a user