Configuring an ASP.NET web app with GSuite Gmail SMTP

This one took me several days to configure as it seems like Google has been constantly upgrading its security rules and so I found a lot of solutions online that no longer work. It’s possible this article may get outdated soon but at the time of writing, this is what made my “Contact Us” page work with GSuite’s Gmail.

These are the following changes you will need to make:

  1. Domain Admin to allow users to enable 2-step verification

    • Login to the GSuite Admin Console using an Admin account
    • Navigate to Security
    • Click on Basic Settings
    • Enable the “Allow users to turn on 2-step verification”
  2. User to enable 2-step verification

    • Login to GSuite using the account that will be used for sending emails
    • On the My Account dashboard, click on “Sign-in & Security
    • On the section Signing in to Google, click on “2-Step Verification”
    • Turn on “2-Step Verification”
    • Fill your details and follow the instructions required to finish 2-step verification
  3. User to generate an app password

    • On the same User account, navigate to  Signing in to Google and click “App paswords”
    • Generate an app password and give it an app name
    • Copy the generated app password for use on step4 below
  4. Update your web application web.config

          <smtp from="{defaultFromEmail}" deliveryMethod="network">
             <network host="" userName="{userEmail}" password="{appGeneratedPassword}" port="25" enableSsl="true">

Those steps did the job for me. I did not need to enable less secure apps to be able to login.