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.
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
)install dependencies
npm install
define required environment variables:
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 bodystart the server
npm start
Testing Signup Flow
Gmail allows to have multiple user name aliases on the same account by using pattern: username+VariableSuffix@gmail.com
. We can leverage this to emulate email server. So we change the page.assignVar
for the following value:
It is supposed to resolve in the email addresses like: joe+test1@gmail.com, joe+test2@gmail.com and so on.
The command page.assignVarRemotely
takes in the following 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:
Last updated