How to add Microsoft Mailbox in Mailivery

Add Outlook / Office accounts to Mailivery by generating a secure embeddable URL and iframing it into your application.

To add an Outlook or Office account to Mailivery, generate a secure embeddable URL and iframe it into your application. Users fill in their basic details and complete the OAuth login flow.

1. Generate a Secure Embeddable URL

You can append extra query parameters to the URL when generating the secure embeddable URL. That data is returned to you in the meta query string of the return URL after the flow completes.

curl --request GET \
     --url https://app.mailivery.io/api/v1/embed/form/secure \
     --header 'accept: json' \
     --header 'authorization: Bearer <<token>>'
GET /api/v1/embed/form/secure HTTP/1.1
Accept: json
Authorization: Bearer <<token>>
Host: app.mailivery.io
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://app.mailivery.io/api/v1/embed/form/secure', [
  'headers' => [
    'accept' => 'json',
    'authorization' => 'Bearer <<token>>',
  ],
]);

echo $response->getBody();
const fetch = require('node-fetch');

const url = 'https://app.mailivery.io/api/v1/embed/form/secure';
const options = {method: 'GET', headers: {accept: 'json', authorization: 'Bearer <<token>>'}};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error('error:' + err));

⚠️

The embeddable URL is unique and time-limited.

The embeddable URL is only valid for 10 minutes and will return a 404 after expiry.

{
    "data": {
        "url": "http://mailivery.test/embed/form?expires=1707257884&identifier=eyJpdiI6Ijk4RXRIOHJxZ3VyTkh3dWxUNnh4VXc9PSIsInZhbHVlIjoiNUUwTFdnRU14ZkFBaFdCcjVuQjZ4L0NZYlVzMXErV1dMUnhGd2FLTTlLWHZlc1psdkMxeXN3ZnRYWU9lTDhCZzN3a1RrOWl5RWM2cGs3djRiZEZLaEE9PSIsIm1hYyI6IjhiMWE0OGU2M2VhZjg2OTI4M2ExNGQyZTc4MzBjYmRmYjU0ZTFmMDkwYzFkMTVkYTE2Nzc3ZTc4YmViMGQzNmYiLCJ0YWciOiIifQ%3D%3D&meta=woodpecker_context%3Dd3asf35dase45g323%26email%3Dmarcin.madejski%40outlook.com&signature=552b2c4f08863f901380a9ba9fb9feb957e21fec2f89747a61abd5ae8c39a1f8"
    },
    "success": true,
    "status": 200,
    "code": "EMBED_FORM_URL_FETCHED",
    "message": "Embed form url fetched successfully"
}

In the example above, woodpecker_context and email were passed as parameters and returned in the meta query string of the signed URL.


2. Get Data After Successful Authentication

After a user successfully adds a Microsoft account, they are redirected to the URL you submitted in the embed form settings.