Pop3ClientMk(config)
Creates a POP3 client and connects to the server: new docly.Pop3ClientMk(config). The client keeps the connection open, so several calls can share it. Call disconnect() when you are done.
Methods:
list()— one { index, uid } per message.getMessage(index)— the whole message, by its 0-based index.getHeader(index)— the same message object, with headers only.delete(index)— marks the message for deletion. POP3 deletes it when the connection is closed with disconnect().disconnect()— closes the connection. Returns true, or false when it was already closed.
Parameters
configobject | stringrequiredConnection settings: hostname, port, useSsl, username, password and method. useSsl: true connects with TLS from the start; false (default) uses STARTTLS when the server offers it. method is Login (default), CRAMMD5, SaslOAuth or OAuth2 — for OAuth, password is the access token. Default port 110. Or pass the path to a document under #/ that holds these values, such as "#/My Pop3": a path reads the values of that document, the same as docly.getJson("#/My Pop3"). Throws "Mail configuration document not found" if there is no such document.
Returns
The client object with the methods above. Throws if the connection or the login fails. A message object has MessageId, Date, From, To, Cc, Bcc, Subject, HtmlBody, TextBody, Body (the HTML body, or the text body when there is none), Headers (an object of header name and value) and Attachments — a list of { FileName, ContentType, ContentId, Base64, Headers }.
Example
let pop3 = new docly.Pop3ClientMk({
"hostname" : "pop.example.com",
"port" : 995,
"useSsl" : true,
"username" : "login",
"password" : "pass"
});
let subjects = [];
try {
for (let m of pop3.list()) {
let msg = pop3.getHeader(m.index);
subjects.push(msg.Subject);
}
} finally {
pop3.disconnect();
}
return subjects;