Example with IMAP bridge
Nowadays there are many specialized services providing a REST API to access your inbox remotely. But it comes with an expense. If you want to obtain REST API for free, you can simply use a bridge server connected to your email provider (e.g. Gmail) by IMAP or SMTP. Puppetry is distributed with an example of a bridge to Gmail.
To setup and run the bridge demo we perform the following steps:
- download and extract content of the folder to an arbitrary location (e.g.
/var/www/gmail-bridge
) - install dependencies
npm install
EID_EMAIL=[email protected]
EID_PASSWORD=gmail password
EID_SECRET=secret
EID_NODE_SERVER_PORT=3500
EID_NODE_SERVER_HOST=127.0.0.1
To make it really work with Gmail, please, enable 2-step verification and generate an App password. This password you shall use for
EID_PASSWORD
- adjust the body of
parseActivationLink
function to parse the desired value (e.g. activation link) from email body - start the server
npm start
Gmail allows to have multiple user name aliases on the same account by using pattern:
[email protected]
. We can leverage this to emulate email server. So we change the page.assignVar
for the following value:joe+test{{ counter() }}@gmail.com
It is supposed to resolve in the email addresses like: [email protected], [email protected] and so on.
The command
page.assignVarRemotely
takes in the following configuration:
page.assignVarRemotely configuration
Basically we configure
page.assignVarRemotely
to request the bridge for TEST_EMAIL
with intervals of 1 seconds and the timeout of 600 seconds. The bridge is expected to parse email body if any available for the activation link. In case of NodeBB it uses the following function:function parseActivationLink( text ) {
const re = /(http\:[^\"]+4567\/con[^\"]+)/g,
res = text.match( re );
return res ? res[ 0 ].replace( "=\r\n", "" ) : null;
}
The parser function of command configuration simply proxies the value from a result such as
{ value: "ACTIVATION_LINK" }
. Here you can put the parsing logic if your bridge/API doesn't do the parsing. Any falsy return of this function causes the command to proceed polling. Note also that we use environment variable
EID_SECRET
to pass the api key to the bridge service.As we run tests we get from the bridge an output like this one:

Gmail Bridge output
Last modified 4yr ago