mail page imap connection mime 5 bis rest 16 login page 7
This commit is contained in:
parent
1ce37420bd
commit
8b0cac370b
@ -13,13 +13,32 @@ console.log('Environment Variables:', {
|
|||||||
|
|
||||||
// Helper function to get stored credentials
|
// Helper function to get stored credentials
|
||||||
function getStoredCredentials() {
|
function getStoredCredentials() {
|
||||||
|
// Server-side: use environment variables
|
||||||
if (typeof window === 'undefined') {
|
if (typeof window === 'undefined') {
|
||||||
// Server-side: use environment variables
|
const user = process.env.IMAP_USER;
|
||||||
|
const password = process.env.IMAP_PASSWORD;
|
||||||
|
const host = process.env.IMAP_HOST;
|
||||||
|
const port = process.env.IMAP_PORT;
|
||||||
|
|
||||||
|
if (!user || !password || !host || !port) {
|
||||||
|
console.error('Missing IMAP environment variables:', {
|
||||||
|
hasUser: !!user,
|
||||||
|
hasPassword: !!password,
|
||||||
|
hasHost: !!host,
|
||||||
|
hasPort: !!port
|
||||||
|
});
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log the actual password length for debugging
|
||||||
|
console.log('Password length:', password.length);
|
||||||
|
console.log('Password characters:', password.split('').map(c => c.charCodeAt(0)));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
user: process.env.IMAP_USER,
|
user,
|
||||||
password: process.env.IMAP_PASSWORD,
|
password: password.replace(/\\/g, '\\\\'), // Escape backslashes
|
||||||
host: process.env.IMAP_HOST,
|
host,
|
||||||
port: process.env.IMAP_PORT
|
port
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,23 +148,50 @@ function createImapConnection(config: any): Promise<Imap> {
|
|||||||
host: config.host,
|
host: config.host,
|
||||||
port: config.port,
|
port: config.port,
|
||||||
tls: true,
|
tls: true,
|
||||||
tlsOptions: { rejectUnauthorized: false },
|
tlsOptions: {
|
||||||
|
rejectUnauthorized: false,
|
||||||
|
servername: config.host
|
||||||
|
},
|
||||||
authTimeout: 10000,
|
authTimeout: 10000,
|
||||||
connTimeout: 10000,
|
connTimeout: 10000,
|
||||||
debug: console.log,
|
debug: console.log,
|
||||||
autotls: 'always',
|
autotls: 'always',
|
||||||
keepalive: true
|
keepalive: true,
|
||||||
|
xoauth2: false,
|
||||||
|
xoauth: false
|
||||||
});
|
});
|
||||||
|
|
||||||
imap.once('ready', () => resolve(imap));
|
imap.once('ready', () => {
|
||||||
|
console.log('IMAP connection established successfully');
|
||||||
|
resolve(imap);
|
||||||
|
});
|
||||||
|
|
||||||
imap.once('error', (err: ImapError) => {
|
imap.once('error', (err: ImapError) => {
|
||||||
console.error('IMAP connection error:', err);
|
console.error('IMAP connection error:', err);
|
||||||
|
console.error('Error details:', {
|
||||||
|
type: err.type,
|
||||||
|
textCode: err.textCode,
|
||||||
|
source: err.source
|
||||||
|
});
|
||||||
reject(err);
|
reject(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
imap.once('end', () => console.log('[connection] Ended'));
|
imap.once('end', () => console.log('[connection] Ended'));
|
||||||
imap.once('close', () => console.log('[connection] Closed'));
|
imap.once('close', () => console.log('[connection] Closed'));
|
||||||
|
|
||||||
imap.connect();
|
try {
|
||||||
|
console.log('Attempting to connect to IMAP server...');
|
||||||
|
console.log('Using credentials:', {
|
||||||
|
user: config.user,
|
||||||
|
passwordLength: config.password.length,
|
||||||
|
host: config.host,
|
||||||
|
port: config.port
|
||||||
|
});
|
||||||
|
imap.connect();
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error during IMAP connection:', err);
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user