Skip to main content

Update #15 - Using Gmail App Password to Get Alerts!

Date: May 22nd, 2025
Category: Security / Automation
Backlink: Update #14 – Auto-Banning Fail2Ban IPs Based on AbuseIPDB Reputation


I made a new Gmail account for alerts on my VPS.

I created a new app password:

2025-05-22 17_17_11-App passwords — Mozilla Firefox.png

I installed a mail alert system via msmtp (Lightweight SMTP Relay Client) with Gmail Support:

sudo apt update
sudo apt install msmtp msmtp-mta -y

I hit no on this screen here:
2025-05-22 17_18_20-App passwords — Mozilla Firefox.png

I made a hidden file using this command:

sudo nano ~/.msmtprc

I filled in my email and app password within the file:

2025-05-22 17_23_26-App passwords — Mozilla Firefox.png

I secured the file using:

sudo chmod 600 ~/.msmtprc

The 600 meaning:
6 = read (4) + write (2) = read/write for the owner
0 = no permission for group
0 = no permission for others

I tested the file by echoing myself an email:

echo "Success! Email is working." | msmtp -v <your.email@here.com>

If you have the app password set up and followed along you will get a email. It should say success on the bottom after running the command:

image.png

You can now use this to set up alerts for all different kinds of thing which I will do.