All technological notes.
postfix on Redhat8# switch to root user
su - root
sudo apt upgrade -y
sudo apt install -y postfix mailutils
SASL:
Simple Authentication and Security Layer/etc/postfix/sasl to store email’s credential
/etc/postfix/sasl/sasl_passwd is used to configure Gmail address and App Password.sudo mkdir -p /etc/postfix/sasl
sudo vi /etc/postfix/sasl/sasl_passwd
# [smtp.gmail.com]:587 your_gmail_address:your_app_pwd
.db file)sudo postmap /etc/postfix/sasl/sasl_passwd
ls -l /etc/postfix/sasl/
# -rw-r--r-- 1 root root 58 Nov 22 19:24 sasl_passwd
# -rw-r--r-- 1 root root 12288 Nov 22 19:25 sasl_passwd.db
# change ownership
sudo chown root:root /etc/postfix/sasl/sasl_passwd /etc/postfix/sasl/sasl_passwd.db
# change mode
sudo chmod 0600 /etc/postfix/sasl/sasl_passwd /etc/postfix/sasl/sasl_passwd.db
ls -l /etc/postfix/sasl/
postfix/etc/postfix/main.cf# backup configuration file
cp /etc/postfix/main.cf /etc/postfix/main.cf.bkp
vi /etc/postfix/main.cf
# find and edit
# configure relay host
relayhost = [smtp.gmail.com]:587
# Append to the end of file
# Enable SASL authentication for postfix
smtp_sasl_auth_enable = yes
# Prevent anonymous authentication
smtp_sasl_security_options = noanonymous
# specify location of sasl_passwd file
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
# user encryption for tls
smtp_tls_security_level = encrypt
# specify the cafile
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
sudo systemctl restart postfix
sudo systemctl status postfix
# use terminal to input email details
sendmail target@email
# To: target@email
# Subject: Test mail #1
# This is just a test email
# ctrl + D to exit

crontab -e
# add the following
# send hellow world to the target email
MAILTO="target@gmail"
* * * * * echo "Hello world"
crontab -e
* * * * * echo "Subject: Email Automation Test - $(date)\nFrom: target@gmail\nTo: target@gmail\n\n$(date)Auto email." | sendmail -v target@gmail