Saturday, December 26, 2020

E-Mail notifications in FreeNAS using Gmail

Setting up email alerts is a smart way of making sure nothing unexpected happens on a FreeNAS server without knowing about it or having to check the UI every now and then. A "should be straigthforward" way ough to be setting up a gmal account as the outgoing email. Nevertheless, it is not as simple as clicking "yeah, sure, email me".

Objective

Get a working E-Mail notification from FreeNAS by using a Gmail E-Mail address for sending the messages.

Overview

FreeNAS needs an smtp server and corresponding E-Mail account credentials to send E-Mails. E-Mails cannot be sent directly from within FreeNAS without an E-Mail server. Additionally, using a Gmail address with the corresponding account password does not work either.  The steps to get such a setup running are briefly as follows,

  1. Get a Gmail E-Mail address,
  2. Allow "App password" access to the E-Mail account, and
  3. Set up FreeNAS E-Mail service.

Settings in the Google account

This is the first step in configuring sending E-Mails through a gmail account. Basically, a new App passsword is required for FreeNAS. Connecting and sending emails via the username and password merely did not work in my case, not even when enabling "Allow less secureapps". So to properly set up access the following needs to be done,

  1. Log in to the Google account.
  2. Go to Security.

    Google account securities tab

  3. Enable 2 Factor Authentication (this is required for step 4!).

    Enable two-step verification in the securities tab.

  4. Once 2 Factor Authentication is enabled, an option becomes avilable to create App passwords.

    App passwords option becomes available afect enabling 2FA
  5. Create a new App password and copy it to the clipboard.
    Generate a new App password for FreeNAS and copy it to the clipboard.

Once this is done, the settings from Gmail side are complete.

Settings in FreeNAS

  1. Go to System/Email and adjust the settings according to the details below.

    FreeNAS System/Email settings showing the fields to make it work with Gmail
    From E-Mail: ChooseItToYourLiking
    Outgoing Mail Server: smtp.gmail.com
    Mail Server Port: 465
    Security: SSL (Implicit TLS)
    SMTP Authentication: Ticked
    Username: example@gmail.com
    Password: YourAppPassword

Once this is done, a test E-Mail can be sent by clicking "SEND EMAIL". If all above steps were followed, a test notification wil arrive in the E-Mail box associated with the root user (!). Following this, an alert service can be set up as well. Without too much details,

  1. Go to System/Alert Services.
  2. Click "Add" and choose Type/Email.
  3. Fill out your email address and click "SEND TEST ALERT".

This should be working now as well and the type of alerts cn be configured based on user needs.

No comments:

Post a Comment