imap.connect(config) Last updated: 30. May 2026

API only function

Creates a new imap session and connects to server.

See also: Send mail from API function Sending forms by e-mail

Parameters

Name Type Description
config object

Uses same setup as POP3. But also with the property

"method" - with one of the following values: Login, CRAMMD5 or SaslOAuth

Returns

An object with the imap session.

Example

Code example (JS)

JS is normal JavaScript either running in the browser or on the Docly™ server.
// Configure connection (same setup as POP3 + a method property)
let config = {
    "hostname" : "serverhost",
    "port" : 143,
    "useSsl" : true,
    "username" : "login",
    "password" : "pass",
    "method" : "Login"
};

let i = imap.connect(config);
let count = imap.getCount(i);
if (count > 0) {
    let msg = imap.getMessage(i, 0);
    imap.delete(i, msg);
    return msg;
}
return "No emails in inbox";