# Outgoing Email via Webhooks

A “Webhook” protocol is available to select when creating a new outgoing email server.

## Create a new Outgoing Webhook Server

1. Access **Admin>System Administration>System>Email Settings**

<figure><img src="https://1375663122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhlW9jKl7dcDggHAPhNU9%2Fuploads%2FFIIuUeazr2U09GsrNRHP%2FScreenshot%202024-09-26%20at%206.49.21%E2%80%AFAM.png?alt=media&#x26;token=65d4c86b-3dac-458b-a43c-6828f20bb4db" alt=""><figcaption></figcaption></figure>

2. In the **Outgoing Email** section of the **Email Settings window**, click ***Add***, to create a new server.  To modify an existing configuration, highlight the row and click Open.  Here, you can also test the configuration.

<figure><img src="https://1375663122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhlW9jKl7dcDggHAPhNU9%2Fuploads%2FHozGRgAVDqpFvlAj9jsy%2FScreenshot%202024-09-26%20at%207.05.48%E2%80%AFAM.png?alt=media&#x26;token=8f096643-7a05-401b-8351-dd1560a5ebaa" alt=""><figcaption></figcaption></figure>

3. Select the '**Webhook'** Protocol from the list.  If the Webhook protocol is not listed, please contact [Alemba Support ](mailto:Support@Alemba.com)for assistance to add the protocol.

<figure><img src="https://1375663122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhlW9jKl7dcDggHAPhNU9%2Fuploads%2FOGfetMEpg3JjGDuT1Isj%2FScreenshot%202024-09-26%20at%206.53.53%E2%80%AFAM.png?alt=media&#x26;token=49c0f3bd-28ca-43d3-b9ff-6f2fc7bf045a" alt=""><figcaption></figcaption></figure>

4. Configure the Webhook widget:

* Payload URL – This is the webhook endpoint. E.g. the endpoint of the Azure Logic App.
* Secret – This is an optional parameter which will be passed within the webhook request header.  It can be used for extra security at the webhook endpoint.

![](https://content.gitbook.com/content/hlW9jKl7dcDggHAPhNU9/blobs/AaotivXTkYeWkvnQepbo/0)

5. When emails are sent, they will appear as recent deliveries. You can check whether they were successful or not. You can also redeliver previous deliveries.

![](https://content.gitbook.com/content/hlW9jKl7dcDggHAPhNU9/blobs/dRArN846xfbMns6ur5Lx/1)

## Logic App Configuration

1. Create Logic App with an HTTP Trigger.
2. Paste the following into the Request Body JSON Schema field of the trigger:

```
{
    "properties": {
        "Action": {
            "type": "string"
        },
        "Email": {
            "properties": {
                "Attachments": {
                    "items": {
                        "properties": {
                            "FileData": {
                                "type": "string"
                            },
                            "FileName": {
                                "type": "string"
                            }
                        },
                        "required": [
                            "FileName",
                            "FileData"
                        ],
                        "type": "object"
                    },
                    "type": "array"
                },
                "Bcc": {
                    "type": "string"
                },
                "BodyHtml": {
                    "type": "string"
                },
                "BodyPlainText": {},
                "Cc": {
                    "type": "string"
                },
                "From": {
                    "type": "string"
                },
                "FromAddress": {},
                "FromName": {},
                "Priority": {
                    "type": "string"
                },
                "ReceiptRecipient": {},
                "ReplyTo": {
                    "type": "string"
                },
                "Subject": {
                    "type": "string"
                },
                "To": {
                    "type": "string"
                }
            },
            "type": "object"
        }
    },
    "type": "object"
}
```

3\.  Add an “Initialize variable” action where the variable name is attachment and the type is array:&#x20;

<figure><img src="https://content.gitbook.com/content/hlW9jKl7dcDggHAPhNU9/blobs/FN8nOcmeB0uONs1OHJty/2" alt=""><figcaption></figcaption></figure>

4\.  Add a “For each” action which will loop through the Attachments from the trigger and will append the FileData and FileName to the attachment array:

<figure><img src="https://content.gitbook.com/content/hlW9jKl7dcDggHAPhNU9/blobs/t9elI3AJgAPb6tFWlNpl/3" alt=""><figcaption></figcaption></figure>

5\.  Add a “Send an email (V2)” action. Configure the connection details to the email server and fill it out as per this screenshot:&#x20;

<figure><img src="https://content.gitbook.com/content/hlW9jKl7dcDggHAPhNU9/blobs/hX5Np4w7GYJAuqPH7vsq/4" alt=""><figcaption></figcaption></figure>

6\.  Add a “Response” action to return a 200 status code and a message to say the email had been processed successfully.&#x20;

<figure><img src="https://content.gitbook.com/content/hlW9jKl7dcDggHAPhNU9/blobs/dj4ez97wUwOVJSnVavlF/5" alt=""><figcaption></figcaption></figure>
