February 11, 2021

Fedora 32 -- setting up postfix

After contemplating setting up exim, I decided to go with postfix. Either would have been a good choice, but postfix certainly won't be a bad choice.

Basic install

su
dnf -y install postfix
systemctl start postfix
systemctl enable postfix

The following commands are useful to monkey with postfix:

systemctl reload postfix
systemctl stop postfix
systemctl status postfix
Look in /var/log/maillog for messages from Postfix.

mailx

This is the ancient simple command line MUA that old unix hacks know and love. Just the thing to test a mail setup.

Remember, "x" exits and makes no changes. Typing "q" exits but will leave mail marked as "U" (unread) rather thant "N" (new).

dnf -y install mailx

Configuring postfix

There are a bunch of files in /etc/postfix. The most important is probably main.cf.

The first thing I do is set myhostname to "casting.as.arizona.edu". This is not the name of the machine I am on, but is the name of the externally visible firewall box that relays port 25 to the machine I am on. We will see if this is correct. This did not work out because of the need to reference this in "inet_interfaces" below. I made sure this FQDN was in /etc/hosts and then set it to:

myhostname = crater.as.arizona.edu
Despite things in the main.cf comments that indicate otherwise, I found that I had to make the following change to get postfix to listen to the external network and not just localhost.
#inet_interfaces = localhost
inet_interfaces = $myhostname, localhost

Finally we set mynetworks to

mynetworks = 192.168.1.0/24, 127.0.0.0/8

Firewall

The system I am installing it on runs firewalld already, so I can skip the following install steps:
su
dnf -y install firewalld
systemctl enable firewalld
systemctl start firewalld
To open the port for smtp (port 25) do the following. I just want to listen for incoming mail on this host, and don't want to allow other hosts to submit mail, so I leave those lines commented out.
firewall-cmd --permanent --add-service=smtp
# firewall-cmd --permanent --add-service=submission
# firewall-cmd --permanent --add-service=smtps
# firewall-cmd --permanent --add-port=465/tcp
firewall-cmd --reload
firewall-cmd --list-all

procmail

su
dnf -y install procmail
Then place this in your /home/user/.forward
"|/usr/bin/procmail"
And set up a .procmailrc

Instructions for debian and exim

Emails are sent out through the University email gateway at smtpgate.email.arizona.edu, so thermo has to have visibility of the Internet. It was also necessary to register thermo with UITS as a permitted email sender. I believe I had to contact UITS (back in 2014) to do this.

The email system was set up on thermo using the exim4 package. Here are the steps I needed to perform:

  - login as root
  - install exim4 package (if not already installed)
  - edit /etc/exim4/update-exim4.conf.conf
    - change these two parameters:
      - dc_eximconfig_configtype='smarthost'
      - dc_smarthost='smtpgate.email.arizona.edu'
    - I think I also changed this parameter (was it just 'thermo'?):
      - dc_other_hostnames='thermo.as.arizona.edu'
  - edit /etc/mailname
    - Change the line from thermo to thermo.as.arizona.edu
    - This sets the name of the sending system in the emails.
  - run update-exim4.conf
    - This parses the new configuration.
    - This is found in /usr/sbin, so it can be called by root from anywhere.
    - There should be no response.
  - run /etc/init.d/exim4 restart
    - This restarts exim4.
    - It should respond with:
      - [ ok ] Restarting exim4 (via systemctl): exim4.service.


Have any comments? Questions? Drop me a line!

Adventures in Computing / tom@mmto.org