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
|
||||
function getStoredCredentials() {
|
||||
// Server-side: use environment variables
|
||||
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 {
|
||||
user: process.env.IMAP_USER,
|
||||
password: process.env.IMAP_PASSWORD,
|
||||
host: process.env.IMAP_HOST,
|
||||
port: process.env.IMAP_PORT
|
||||
user,
|
||||
password: password.replace(/\\/g, '\\\\'), // Escape backslashes
|
||||
host,
|
||||
port
|
||||
};
|
||||
}
|
||||
|
||||
@ -129,23 +148,50 @@ function createImapConnection(config: any): Promise<Imap> {
|
||||
host: config.host,
|
||||
port: config.port,
|
||||
tls: true,
|
||||
tlsOptions: { rejectUnauthorized: false },
|
||||
tlsOptions: {
|
||||
rejectUnauthorized: false,
|
||||
servername: config.host
|
||||
},
|
||||
authTimeout: 10000,
|
||||
connTimeout: 10000,
|
||||
debug: console.log,
|
||||
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) => {
|
||||
console.error('IMAP connection error:', err);
|
||||
console.error('Error details:', {
|
||||
type: err.type,
|
||||
textCode: err.textCode,
|
||||
source: err.source
|
||||
});
|
||||
reject(err);
|
||||
});
|
||||
|
||||
imap.once('end', () => console.log('[connection] Ended'));
|
||||
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