Created
October 25, 2024 16:48
-
-
Save BananaAcid/2243872aca52bc48291b4fc44763d55a to your computer and use it in GitHub Desktop.
IMAP Auth for nodejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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