Introduction:
This blog post is a second part continuation of an earlier post regarding shell script that checks CPU Utilization for a given period of time. In this article, I will share to you a comprehensive step by step procedure on how to send an email message via linux machine, using postfix service. After configuring this, we will have a new article that will show how to integrate threshold breaching shell script and alert notification via email message, combining all three articles to come up with a very robust email notification alerting upon CPU Utilization Breach via shell script.
Installation and Configuration of Postfix
Postfix is a widely-used open-source mail transfer agent (MTA) in Unix-like operating systems. It serves as the backbone for routing and delivering email across networks, handling tasks such as receiving, processing, and forwarding messages. Known for its security, reliability, and extensibility, Postfix offers a robust solution for managing email services in both small-scale setups and large enterprises.
1. Install Postfix in your linux machine
yum install -y postfix
2. Start the Postfix service and check its status
systemctl start postfix
systemctl status postfix
3. Configuring Postfix
vi /etc/postfix/main.cf
#Config
mydomain = localhost
relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = encrypt
smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt
inet_interfaces = all
#Ensure that the other “inet_protocols = all”, “smtp_tls_security_level = encrypt” and “inet_interfaces = localhost” in the configuration file are commented already.
4. Creating sasl_password file
vi /etc/postfix/sasl_passwd
[smtp.gmail.com]:587 <email addr sender>:<gmail app password>
5. Restart Postfix, Postmap Command and chmod Command
systemctl restart postfix
postmap /etc/postfix/sasl_passwd
chmod 600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
6. Send Email Test
echo “Hi Engineer! today is $(date)” > File2
/usr/sbin/sendmail [email protected] < File2
Conclusion
In this article we have seen a very insightful step by step procedure on how to install, configure and use postfix service to send email message via linux machine, in later articles, we’ll integrate the learnings from the CPU Utilization Monitoring Script and then configure a CPU Util Breaching Script with Alert Notification via Email all in one Script.
Related Topics
Linux Articles:
CPU Utilization Monitoring Script
Tips on How to Pass RedHat Certified Systems Administration Exam
Career Story of a Linux Application Support Engineer: A Journey of Dedication, Resilience, and Excellence
Tips on How to Become a Successful Linux Application Support Engineer
Is Linux in Demand in the Philippines
Unlocking Foundations in Devops: Why Linux is crucial?
Observability Related Topics:
SRE Observability Course
What is Observability?
How to setup a Node Exporter?
Deploy Node Exporter as a Daemon Service
Configure Prometheus Service
4 thoughts on “Email Sending Using Postfix Service on Linux Machine”
Comments are closed.