email

Provides methods for working with email via IMAP.

If you are using oxygen.conf.js, email module must be added.

modules: ['web', 'log', 'assert', 'date', 'db', 'email']

getLastEmail

Retrieves last unseen email.

Parameters:

Name

Type

Description

sinceMinutes

Number

Search for emails received since the specified amount of minutes into past.

subject

String|Regex

Return email matching the specified subject.

timeout

Number

Timeout (in milliseconds) for waiting for the message to arrive.

Returns:

Object - Email body and TO, FROM, SUBJECT, DATE headers.

email.init('[YOUR_EMAIL]@gmail.com', 'password', 'imap.gmail.com', 993, true, 3000)
var mail = email.getLastEmail(60, 'email subject', 5000)
log.info(mail)

init

Set email connection details.

Parameters:

Name

Type

Description

user

String

Username (e.g. 'your@email.address').

password

String

Password.

host

String

Host name (e.g. 'imap.gmail.com').

port

Number

Port number (e.g. 993).

tls

Boolean

true to use TLS, false otherwise.

authTimeout

Number

Authentication timeout in milliseconds.

enableSNI

Boolean

optional Enable sending SNI when establishing the connection. This is required for some mail servers. Default is false.

email.init(
'[YOUR_EMAIL]@gmail.com', // email address
'password', // password
'imap.gmail.com', // IMAP server address. Current example is for Gmail
993, // IMAP server port. Current example is for Gmail
true, // specifies whether to use TLS or not. Current example is for Gmail
3000 // connection timeout in milliseconds
)