This article has not been completed yet. However, it may already contain helpful Information and therefore it has been published at this stage.

Prerequisites:

Setting Up the SMTP Relay

# Check if SMTP is installed before installing it.
 $smtp = get-WindowsFeature "smtp-server"
 if(!$smtp.Installed){
 write-host "SMTP is not installed, installing it..." -ForegroundColor red
 add-WindowsFeature $smtp
 }
else{
 write-host "SMTP is already installed!" -ForegroundColor Cyan
 }

Sources:

How to Set Up an Office 365 SMTP Relay with Connectors

https://lexisnexis.custhelp.com/app/answers/answer_view/a_id/1101986/~/install-and-configure-an-smtp-relay-for-office-365-exchange-online

https://it-infrastructure.solutions/docker-office-365-mail-relay/

Install SMTP Server and Telnet with PowerShell
Summary SharePoint and general app servers often use the SMTP Service to integrate e-mail into the systems functionality. Since Windows supports a well vetted SMTP Service, using the built-in application is often the best choice. With the said, when testing your app functionality with e-mail, Teln…