# Mail Server Settings

### Gmail / Google Mail: POP3 / IMAP

1. Enable POP3 and/or IMAP in your Gmail settings: \
   See <https://support.google.com/a/answer/105694?hl=en>
2. Create an Google *App Password* for Squirrel:\
   See <https://support.google.com/accounts/answer/185833>
3. Use the *App Password* instead of the normal Gmail user password in your Squirrel subscription document

| Protocol | Mail Server    | Port |
| -------- | -------------- | ---- |
| POP3S    | pop.gmail.com  | 995  |
| IMAPS    | imap.gmail.com | 993  |

### Microsoft 365 Outlook Mail: POP3 / IMAP with OAuth 2.0

The support for OAuth 2.0 *Client Credentials* grant type with IMAP and POP3 access on the Azure platform is available as of July 1st, 2022. Please follow the steps carefully in setting up the application id and the client credentials:

* [Microsoft identity platform and the OAuth 2.0 client credentials flow](https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow)
* [Authenticate an IMAP, POP or SMTP connection using OAuth](https://docs.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth)

#### Important Notes

* Add the *Application* *Type* API permission *Office 365 Exchange Online* > **I***MAP.AccessAsApp* or *POP.AccessAsApp* depending on the protocol to be used.
* These API permissions do require admin consent.
* Do not forget to issue the required PowerShell commands (see below).
* Use the hostname *outlook.office365.com* in the connection document.

<figure><img src="/files/z7umQ8Rtaaa0pAdTYoK5" alt=""><figcaption><p>Microsoft Entra</p></figcaption></figure>

#### PowerShell Command Example

{% code overflow="wrap" lineNumbers="true" %}

```powershell
Install-Module -Name ExchangeOnlineManagement
Import-module ExchangeOnlineManagement
Connect-ExchangeOnline -Organization {Azure-Tenant-ID}
New-ServicePrincipal -AppId {Enterprise-Application-ID} -ServiceId {Enterprise-Object-ID}
Add-MailboxPermission -Identity "{Email-Address}" -User {Enterprise-Application-ID} -AccessRights FullAccess
```

{% endcode %}

{% hint style="warning" %}
The client secret generated by Microsoft 365 will expire after the specified period and will have to be renewed.
{% endhint %}

#### Field Assignments

<table><thead><tr><th width="294">Subscription Document</th><th>Example value</th></tr></thead><tbody><tr><td>Authorization Token Endpoint</td><td>https://login.microsoftonline.com/11111111-2222-3333-4444-55555555555/oauth2/v2.0/token</td></tr><tr><td>Authorization Scope</td><td>https://outlook.office365.com/.default</td></tr><tr><td>Client/Application ID</td><td>66666666-7777-888-9999-11111111111</td></tr><tr><td>Client Value/Secret</td><td>puG8Qak340dhfnskfrieuhnfe3dr.456saa.O</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://squirrel.k43.ch/mail-server-settings.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
