How To: Use Office 365 as SMTP for The Identity Hub
Note
Applies to: On-premise and private Azure Cloud scenarios (not for SAAS www.theidentityhub.com)
The Identity Hub requires a SMTP server to send emails. This can be your Office 365 subscription.
You will need a (shared) mailbox and an Office 365 user account to be able to send mail.
Required information
| Parameter | Description | Value |
|---|---|---|
| from | The email address of an existing (shared) Office 365 mailbox | Recommended is noreply@yourdomain.com |
| username | The login name of a Office 365 user account that can send mail from the (shared) mailbox | usernam@yourdomain.com |
| password | The password of the Office 365 user account that can send mail from the (shared) mailbox | A strong password. Recommended is an app password (see https://support.office.com/en-us/article/Create-an-app-password-for-Office-365-3e7c860f-bda4-4441-a618-b53953ee1183) |
| host | Host name of the Office 365 smtp server | smtp.office365.com |
| port | Port number to connect to the Office 365 smtp server | 587 (recommended), 21 if 587 cannot be used. |
Configuration in the web.config
Warning
It is highly recommended to encrypt the smtp config section.
<system.net>
<mailSettings>
<smtp
deliveryMethod="Network"
from="noreply@yourdomain.com">
<network defaultCredentials="false"
enableSsl="true"
host="smtp.office365.com"
password="[Account Password]"
port="587"
userName="useraccount@domain.com"/>
</smtp>
</mailSettings>
</system.net>
Encrypting the web.config mailsettings section
You can use the U2UConsult.Framework.Configuration.Pkcs12ProtectedConfigurationProvider from the U2UConsult.Framework.dll and a certificate with private key.
Make sure the certificate and its private key are accessible by the account running the The Identity Hub web site (account of the application pool).
- Add the following section to the web.config
<configProtectedData>
<providers>
<add name="CustomProvider" thumbprint="[The thumbprint of the certificate to use]" type="U2UConsult.Framework.Configuration.Pkcs12ProtectedConfigurationProvider, U2UConsult.Framework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=25fd43e98a2121e5" />
</providers>
</configProtectedData>
- Install the U2UConsult.Framework.dll in the GAC using gacutil.exe (see https://docs.microsoft.com/en-us/dotnet/framework/app-domains/how-to-install-an-assembly-into-the-gac)
- Open a command prompt and execute the following command
"aspnet_regiis.exe" -pef "system.net/mailSettings/smtp" "[Path to the folder containing the web.config file]" -prov "CustomProvider"
Note
aspnet_regiis.exe is part of the .NET Framework (https://docs.microsoft.com/en-us/dotnet/framework/install/guide-for-developers)
- Uninstall the U2UConsult.Framework.dll GAC using gacutil.exe (see https://docs.microsoft.com/en-us/dotnet/framework/app-domains/how-to-install-an-assembly-into-the-gac)