This is a cross post from Cocoontech to here. I have used STunnel here since the Homeseer 2 days. Always worked for me.
This post will review how to configure an STunnel proxy and use Google Mail with it. This will work with your Omnipro 2 panel, Elk panel, Home Assistant, OmniLinkBridge plugin, Homeseer, Homeseer OmniPlugin or any automation you have running on your local LAN. Will post another one for using Office 365 Outlook mail. A few months ago switched from GMail to personal Email paid service. The personal email service was working fine until they switched to Office 365 Email. So I switched back to using Gmail notifications.
For Automation / Security here have used:
1 - Google Mail
2 - Outlook Mail
3 - personal Email server
Sending out mostly texts relating to status of security these days.
Switched from Google Mail to personal email server a few months ago and noticed that my personal email service got switched over to Office 365 last week. I was notified of the changes about a month ago.
My automation / security here runs mostly in Linux. For many years have used STunnel and today using STunnel4 on one Linux box.
I point all automation / security boxes to the Ubuntu server port 25 for SMTP mail. I do not do any pop or incoming mail with any automation server or security stuff.
This works fine with any Debian box you have on line (like an RPi). You can also install STunnel in Windows. This post will only cover Linux installation.
Old way
sudo apt update
sudo apt install stunnel4
New way
sudo apt update
sudo apt install snapd
sudo snap install stunnel5
There are examples on your /etc/stunnel/ configuration out there in Internetlandia. Use the following for GMail configuration.
After installation you want to create a certificate file called stunnel.pem
There are examples on your /etc/stunnel/ configuration out there in Internetlandia. Use the following for GMail configuration.
nano /etc/stunnel/stunnel.conf
NOTE: IP address 192.168.244.174 is the Ubuntu box that I am using.
After the above you want to enable STunnel.
nano /etc/default/stunnel4
Put this in the file:
ENABLED=1
Then you want to enable and start the stunnel service
systemctl enable stunnel4.service
systemctl start stunnel4.service
systemctl status stunnel4.service
If you have a typo in the configuration then when you look at the status you will see that the service has exited.
That is all you need to use STunnel. (not really).
Configuring any automation device on your network to use SMTP mail do the following:
1 - SMTP mail address ==> IP of STunnel box and use port 25
IE: 192.168.244.174:25
2 - use your gmail address and password
Send out a test email and you will see "incorrect" password in the logs for GMail.
GMail authentication has changed and now you need a application specfic password for non standard device authentication.
I used name and password and copied this over to a text file.
1 - log in to Google
2 - go to Google Account settings
3 - Go to security - App passwords
4 - add a new app and you will be given a new password. Call the app anything you want. I saved the password such that I could use it multiple times.
5 - now reconfigure your smtp gmail login on any app and use this new password. Send a test email and you will see it working fine.
Create one app configuration and call it myemail and copy the password over to a text file. You can use this password for any of your gmail configurations on your home lan. You can install STunnel on any box at home running Windows or Linux. I use it for all of my security and automation.

This post will review how to configure an STunnel proxy and use Google Mail with it. This will work with your Omnipro 2 panel, Elk panel, Home Assistant, OmniLinkBridge plugin, Homeseer, Homeseer OmniPlugin or any automation you have running on your local LAN. Will post another one for using Office 365 Outlook mail. A few months ago switched from GMail to personal Email paid service. The personal email service was working fine until they switched to Office 365 Email. So I switched back to using Gmail notifications.
For Automation / Security here have used:
1 - Google Mail
2 - Outlook Mail
3 - personal Email server
Sending out mostly texts relating to status of security these days.
Code:
1 - TMobile ==> 5555555555@tmomail.net 2 - AT&T ==> 5551234567@txt.att.net 3 - Verizon ==> 5555555555@vtext.com
My automation / security here runs mostly in Linux. For many years have used STunnel and today using STunnel4 on one Linux box.
I point all automation / security boxes to the Ubuntu server port 25 for SMTP mail. I do not do any pop or incoming mail with any automation server or security stuff.
This works fine with any Debian box you have on line (like an RPi). You can also install STunnel in Windows. This post will only cover Linux installation.
Old way
sudo apt update
sudo apt install stunnel4
New way
sudo apt update
sudo apt install snapd
sudo snap install stunnel5
There are examples on your /etc/stunnel/ configuration out there in Internetlandia. Use the following for GMail configuration.
After installation you want to create a certificate file called stunnel.pem
Code:
openssl genrsa -out key.pem 2048 openssl req -new -x509 -key key.pem -out cert.pem -days 1095 cat key.pem cert.pem >> /etc/stunnel/stunnel.pem
nano /etc/stunnel/stunnel.conf
Code:
cert = /etc/stunnel/stunnel.pem debug = 7 output = /var/log/stunnel.log client = yes [pop3s] accept = 127.0.0.1:11110 connect = pop.gmail.com:995 [smtps] accept = 192.168.244.174:25 connect = smtp.gmail.com:465
After the above you want to enable STunnel.
nano /etc/default/stunnel4
Put this in the file:
ENABLED=1
Then you want to enable and start the stunnel service
systemctl enable stunnel4.service
systemctl start stunnel4.service
systemctl status stunnel4.service
If you have a typo in the configuration then when you look at the status you will see that the service has exited.
That is all you need to use STunnel. (not really).
Configuring any automation device on your network to use SMTP mail do the following:
1 - SMTP mail address ==> IP of STunnel box and use port 25
IE: 192.168.244.174:25
2 - use your gmail address and password
Send out a test email and you will see "incorrect" password in the logs for GMail.
GMail authentication has changed and now you need a application specfic password for non standard device authentication.
I used name and password and copied this over to a text file.
1 - log in to Google
2 - go to Google Account settings
3 - Go to security - App passwords
4 - add a new app and you will be given a new password. Call the app anything you want. I saved the password such that I could use it multiple times.
5 - now reconfigure your smtp gmail login on any app and use this new password. Send a test email and you will see it working fine.
Create one app configuration and call it myemail and copy the password over to a text file. You can use this password for any of your gmail configurations on your home lan. You can install STunnel on any box at home running Windows or Linux. I use it for all of my security and automation.