[root@SysAdmin ~]# yum install postfix
Last metadata expiration check: 4:50:02 ago on Sun 29 Sep
2024 08:18:17 AM +06.
Dependencies resolved.
================================================================================
Package Architecture Version Repository Size
================================================================================
Installing:
postfix x86_64 2:3.5.9-24.el9 appstream 1.4 M
Transaction Summary
================================================================================
Install 1 Package
Total download size: 1.4 M
Installed size: 4.4 M
Is this ok [y/N]: y
Downloading Packages:
postfix-3.5.9-24.el9.x86_64.rpm 425 kB/s | 1.4 MB 00:03
--------------------------------------------------------------------------------
Total 334 kB/s | 1.4 MB 00:04
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: postfix-2:3.5.9-24.el9.x86_64 1/1
Installing : postfix-2:3.5.9-24.el9.x86_64 1/1
Running scriptlet: postfix-2:3.5.9-24.el9.x86_64 1/1
Verifying : postfix-2:3.5.9-24.el9.x86_64 1/1
Installed:
postfix-2:3.5.9-24.el9.x86_64
Complete!
[root@SysAdmin ~]# rpm -qa | grep postfix
postfix-3.5.9-24.el9.x86_64
[root@SysAdmin ~]# cd /etc/postfix/
[root@SysAdmin postfix]# ls
access generic master.cf relocated
canonical header_checks master.cf.proto sasl_passwd
dynamicmaps.cf main.cf postfix-files transport
dynamicmaps.cf.d main.cf.proto postfix-files.d virtual
[root@SysAdmin postfix]# vi main.cf
relayhost = [smtp.gmail.com]:587
myhostname = SysAdmin
[root@SysAdmin postfix]# vi main.cf
#Location of sasl_passwd we saved
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
#Enables SASL authentication for postfix
smtp_sasl_auth_enable = yes
smtp_tls_security_level = encrypt
#Disallow methods that allow anonymous authentication
smtp_sasl_security_options = noanonymous
[root@SysAdmin postfix]# pwd
/etc/postfix
[root@SysAdmin postfix]# mkdir sasl
[root@SysAdmin postfix]# cd sasl/
[root@SysAdmin sasl]# touch sasl_passwd
[root@SysAdmin sasl]# ls
sasl_passwd
#######################################################################
Enable two factor authenticate
App passwords - smtp
your app password for your device - dnbm nrxm kiam fomx
[root@SysAdmin sasl]# vi sasl_passwd
[smtp.gmail.com]:587 dev609dev@gmail.com:dnbmnrxmkiamfomx
#######################################################################
[root@SysAdmin sasl]# pwd
/etc/postfix/sasl
[root@SysAdmin sasl]# ls -ltr
total 4
-rw-r--r--. 1 root root 58 Sep 29 13:31 sasl_passwd
[root@SysAdmin sasl]# postmap sasl_passwd
postmap: warning: /etc/postfix/main.cf, line 752: overriding earlier entry: smtp_tls_security_level=may
[root@SysAdmin sasl]# ls -ltr
total 12
-rw-r--r--. 1 root root 58 Sep 29 13:31 sasl_passwd
-rw-r--r--. 1 root root 12288 Sep 29 13:35 sasl_passwd.db
[root@SysAdmin sasl]# chmod 600 *
[root@SysAdmin sasl]# ls -ltr
total 12
-rw-------. 1 root root 58 Sep 29 13:31 sasl_passwd
-rw-------. 1 root root 12288 Sep 29 13:35 sasl_passwd.db
[root@SysAdmin sasl]# systemctl start postfix.service
####################################################
To send an email using Linux terminal
echo "Test Mail" | mail -s "Postfix
TEST" dev609dev@gmail.com
echo "Message Body Here" | mailx -s
"Subject Here" -a backup_21-09-18.log dev609dev@gmail.com
####################################################
For not to get any notification on the command line:
#smtp_tls_security_level = may
[root@SysAdmin postfix]# systemctl restart
postfix.service
Dependencies resolved.
================================================================================
Package Architecture Version Repository Size
================================================================================
Installing:
postfix x86_64 2:3.5.9-24.el9 appstream 1.4 M
================================================================================
Install 1 Package
Installed size: 4.4 M
Is this ok [y/N]: y
Downloading Packages:
postfix-3.5.9-24.el9.x86_64.rpm 425 kB/s | 1.4 MB 00:03
--------------------------------------------------------------------------------
Total 334 kB/s | 1.4 MB 00:04
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: postfix-2:3.5.9-24.el9.x86_64 1/1
Installing : postfix-2:3.5.9-24.el9.x86_64 1/1
Running scriptlet: postfix-2:3.5.9-24.el9.x86_64 1/1
Verifying : postfix-2:3.5.9-24.el9.x86_64 1/1
postfix-2:3.5.9-24.el9.x86_64
access generic master.cf relocated
canonical header_checks master.cf.proto sasl_passwd
dynamicmaps.cf main.cf postfix-files transport
dynamicmaps.cf.d main.cf.proto postfix-files.d virtual
myhostname = SysAdmin
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
smtp_sasl_auth_enable = yes
smtp_tls_security_level = encrypt
smtp_sasl_security_options = noanonymous
/etc/postfix
[root@SysAdmin postfix]# mkdir sasl
[root@SysAdmin postfix]# cd sasl/
[root@SysAdmin sasl]# touch sasl_passwd
[root@SysAdmin sasl]# ls
sasl_passwd
App passwords - smtp
your app password for your device - dnbm nrxm kiam fomx
/etc/postfix/sasl
[root@SysAdmin sasl]# ls -ltr
total 4
-rw-r--r--. 1 root root 58 Sep 29 13:31 sasl_passwd
postmap: warning: /etc/postfix/main.cf, line 752: overriding earlier entry: smtp_tls_security_level=may
total 12
-rw-r--r--. 1 root root 58 Sep 29 13:31 sasl_passwd
-rw-r--r--. 1 root root 12288 Sep 29 13:35 sasl_passwd.db
[root@SysAdmin sasl]# ls -ltr
total 12
-rw-------. 1 root root 58 Sep 29 13:31 sasl_passwd
-rw-------. 1 root root 12288 Sep 29 13:35 sasl_passwd.db
Tags
RHCSA