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.
Setting up Gmail Bridge Demo
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 )
adjust the body of parseActivationLink function to parse the desired value (e.g. activation link) from email body
start the server npm start
Testing Signup Flow
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:
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:
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:
function parseActivationLink( text ) {
const re = /(http\:[^\"]+4567\/con[^\"]+)/g,
res = text.match( re );
return res ? res[ 0 ].replace( "=\r\n", "" ) : null;
}