Postfix configure (2021 edition)
The doc here is extremely well done (at dec 2021), specially the smtp one, with way to check the result. Recommended.
But it insist of using the ssl system, witch I don't want to use (yet).
Also it makes me install dovecot, witch is probably not necessary atm.
However, parts are much to complicated for me, so I will copy here the relevant part (for my use).
The main types of connections for inbound mail are:
POP or IMAP - these are client protocols and mostly used by user mail clients, but a mail server can also retrieve mail using these protocols.
SMTP - Simple Mail Transfer Protocol is the main protocol used by mail server to, well, transfer mail.
Sending and receiving locally
Install postfix and mailx if it's not default. AFAIK, the local mailing works out of the box. Try it. The command (mail jdd) asks for a subject, then a content. You send the mail typing
(hold control, type D) at the beginning of a line (so after hitting Enter).
zypper in postfix zypper in mailx
Better open two xterm to the server, one as root, the other as user (jdd for me). Of course for this to work, you have to create first the recipient user :-).
As user, typing "mail" (without option) brings you in the mail reader and give a list of the incoming mails if any. Typing the mail number displays the mail.
Default postfix works with mbox, which means that we will use /var/spool/mail/login_user/
You can get mail directly sent to your server. For this you need several things:
Domain name Fixed IP address Correct MX records (but none is enough, in fact)
If you have a Dynamic IP address, seriously reconsider to apply for a fixed address. You are on your own.
First see that a fresh installed postfix is running. This can be done by a telnet session (from the server itself):
>telnet localhost 25 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 your-domain-name ESMTP Postfix
Use quit to exit.
At any moment you can try this test from yous own local workstation, to see if the server is responding to external calls.
right now (dec12, 2021) I *don't* have Postfix displayed, but only ESMTP, may be some install tests broke something.
This works with default config from openSUSE (cp main.cf.rpmnew main.cf), both from root@yourserver and from my own workstation.
without argument check the config and display the defaults, using grep (postconf | grep xxx), you can check if the default meet your needs.
By the way, one as root can read the mailbox of an other user with "mailx -u user-name".
From the outside
Next see that the outside world is able to connect to port 25.
The tool of choice for this is "nmap". Install it on your workstation (not on the server). never use nmap against server you don't own. This is considered as an attack!.
Should report the open ports of your server:
PORT STATE SERVICE 22/tcp open ssh 25/tcp open smtp 119/tcp open nntp
wich is OK, my server being used for usenet (nntp, port 119).
On my config, it worked out of the box, but if you don't have the port 25 open, postfix is only listening to port 25 on localhost, so you need to make it listen to outside systems by giving the next command and restarting postfix, by using the recommended way of changing parameters in /etc/postfix/main.cf, using postconf:
postconf -e "inet_interfaces = all"
Restart postfix by using:
systemctl restart postfix.service
If you use a firewall, you also need to open your firewall. My server is alone on his network/IP, so I don't see any use of a firewall, for now.
The next step is to customize postfix with your identity (do this by replacing example.com by your domain name and hostname by the name of your host in /etc/hostname). Three things should be added and/or changed:
If you wonder what is your hostname, you have probably it just on the left of the terminal prompt, or with the command "hostname".
postconf -e "myhostname = hostname.example.com" postconf -e "mydomain = example.com" postconf -e "mydestination = \$myhostname, \$mydomain, localhost.\$mydomain"
The backslash in front of the $ is needed to get the dollar in this parameter.
On my config, I have one and only one computer under this domain name, so I have no reason to give him a name for postfix. I use "myhostname = example.com" (same as mydomain).
This and the fact than my domain name have two dots, prevent postfix from guessing the domain name from the hostname, so I need the second and third lines above.
Restart postfix. You will now be able to receive mail for login accounts (e.g. root) on example.com .
Install packet mailx, and use the command:
mailx -s test email@example.com < /etc/aliases
to send the content of /etc/aliases to the root account on your system. It should arrive in /var/spool/mail/root.
You may need other setup if you plan to use dovecot. If so read the openSUSE doc.
You can write an MX record on your DNS zone system, but it's not necessary if your server is the same that is listed as A record.
Postfix used to have default alias_map it don't have anymore, so you may have to add:
postconf -e "alias_maps = lmdb:/etc/aliases"
to have /etc/aliases works. Don't forget newaliases and sysctl restart postfix.service :-).