Skip to content

Instantly share code, notes, and snippets.

@BananaAcid
Created October 25, 2024 16:48
Show Gist options
  • Save BananaAcid/2243872aca52bc48291b4fc44763d55a to your computer and use it in GitHub Desktop.
Save BananaAcid/2243872aca52bc48291b4fc44763d55a to your computer and use it in GitHub Desktop.
IMAP Auth for nodejs
// npm install imapflow
import { ImapFlow } from 'imapflow';
const config = {
host: 'ethereal.email',
port: 993,
secure: true,
auth: {}
};
/**
* try to authenticate
**/
export default async function auth(user = {user: null, pass: null}) {
const client = new ImapFlow({
...config,
auth: {...user},
});
let result = {success: false, error: null};
try {
await client.connect();
await client.logout();
result.success = true;
} catch (e) {
result.error = e;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment