Sending Microsoft Exchange Email using Python (and Terraform)

<p>The title of this post is deliberate in the sense that there are hundreds of posts out there about sending emails using Python. In fact, this is something you can achieve with just 5 lines of code and no extra library installed since the smtp library is a default python package. However, I ran into a scenario where I needed to automate emails from my corporate account after the execution of a scheduled job. The problem is, my Azure AD admin has enforced 2FA on our emails so that it&rsquo;s not enough to just provide the email username and password to the smtp library. In other cases your admin might have disabled the SMTP AUTH protocol in your Exchange Online Organization. These two scenarios will raise an insufficient authentication error making it impossible to use the smtp library.</p> <p><a href="https://medium.com/@george_owino/sending-microsoft-exchange-email-using-python-and-terraform-dadaa5c3e72c"><strong>Website</strong></a></p>