# Example with Mailinator

Similar to [Restmail.net](http://restmail.net/) we need user name alias to use with the REST API. so we modify the first steps in the case case as follows:

![Assigning TEST\_USER\_ALIAS and TEST\_EMAIL](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LiIy7jfVRl7GQ6uK-qm%2F-LiIyYpg-JJw8k2sPpTA%2Fmailinator-1.png?alt=media\&token=580b4f9f-1210-4364-b57e-5d9db10d0d8d)

Following [Mailinator API](https://manybrain.github.io/m8rdocs/#message-api) we need to set URL for `page.assignVarRemotely`:

```
https://api.mailinator.com/api/inbox?token={{ env( "EID_SECRET" ) }}&to={{ TEST_USER_ALIAS }}
```

![page.assignVarRemotely configuration for Mailinator (part 1)](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LiIy7jfVRl7GQ6uK-qm%2F-LiIzsEM_hNQomumkFPz%2Fmailinator-2.png?alt=media\&token=70c887a1-1afd-47cb-b64c-a314935a6bc3)

However [Mailinator](https://www.mailinator.com/) unlike [Restmail.net](http://restmail.net/)  doesn't allow to receive last message content with a single request. So we need to take advantage of optional `request function` command parameter:

So we alternate the default fetch logic of `page.assignVarRemotely` as follows:

```javascript
async ( url ) => {
   const inbox = await ( await fetch( url ) ).json(),
         msgHead = inbox.messages
           .reverse()
           .find( msg => msg.subject.includes( "Account Validation" ) ),
         fulMsg = await ( await fetch( `https://api.mailinator.com/api/message?token=YourAPIToken&id=${ msgHead.id }` ) ).json();
  return fulMsg.data.parts.map( p => p.body ).join();
}
```

Thus the command will read the listing and find a message with subject containing `"Account Validation"` string. Then it retrieves and returns the raw body of the matching mail. So the parse function may look like:

```javascript
( text ) => {
    const re = /(http\:[^\"]+4567\/con[^\"]+)/g,
              res = text.match( re );
    return res ? res[ 0 ].replace( "=\r\n", "" ) : null;
}
```

![page.assignVarRemotely configuration for Mailinator (part 2)](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LiIy7jfVRl7GQ6uK-qm%2F-LiJ-iBkOEomJK7TUkzr%2Fmailinator-3.png?alt=media\&token=0ad1c200-5d2b-4ff5-a22b-07b0f89c4822)
