-
Notifications
You must be signed in to change notification settings - Fork 19
Postfix
GitzJoey edited this page Apr 16, 2022
·
4 revisions
Postfix is a free and open-source mail transfer agent (MTA) that routes and delivers electronic mail.
- Install the postfix package and open the firewall for smtp
$ dnf install -y postfix $ firewall-cmd --zone=public --add-service=smtp --permanent $ firewall-cmd --reload
- Remove sendmail
$ dnf remove -y sendmail
- Set Postfix as the default Mail Transfer Agent
$ alternatives --set mta /usr/sbin/sendmail.postfix
- Backup
$ mv /etc/postfix/main.cf /etc/postfix/main.cf.bak
- Edit the configuration file
nano /etc/postfix/main.cf myhostname = $(hostname -f) myorigin = \$myhostname inet interfaces = all inet protocols = ipv4 mydestination = \$myhostname, localhost mynetworks = 192.168.1.0/24, 127.0.0.0/8 10.0.0.0/24
- Restart
$ systemctl enable postfix.service $ systemctl start postfix.service
- Install the mailx email client
$ dnf install -y mailx
- Send a test email to your own external email address.
Update the hostname in the mailx command to match the instance from which you are sending email$ hostname=$(hostname -f) $ echo "External email" | mailx -r root@$hostname -s "Test email subject" [email protected]
- If the email does not appear, you can check the Postfix mail queue
$ mailq $ tail -f /var/log/maillog
- Edit main.cf
$ nano /etc/postfix/main.cf relayhost = [smtp-relay.sendinblue.com]:587 # outbound relay configurations smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = noanonymous smtp_tls_security_level = may header_size_limit = 4096000 $ nano /etc/postfix/sasl_passwd [smtp-relay.sendinblue.com]:587 smtp_username:smtp_password $ postmap /etc/postfix/sasl_passwd $ systemctl restart postfix $ chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db