On this page... (hide)
Postfix configure is one of the most challenging things I know. Postfix is a very easy to configure application (on it's openSUSE default at least), but a very small change can stop all without notice in the logs. Testing is difficult as it needs sending a mail and waiting, sometime forever if the mail don't come nor come back with an error.
Installing "pine" ("alpine", by the way) is much friendlier than mailx :-).
What I need really is to be able to use my server as pop3, imap, smtp server. In current language, this mean I want to be able to fetch my mail from the server (so I need also to receive it on this server), removing it (pop3) or letting it on the server (imap), and send it to the world using the same server.
So at first I need to be able to write mail on the server itself, send it from a server account (for example root) to an other server account (for example jdd), then from jdd on the server to any mail outside (for example the mail I still have on my ISP's account). This is also needed for webmail use.
I fact, I use smtp (sending mail) only for webmail - no relay.
So, install postfix and mailx (easier than pine for basic tests) if it's not default. AFAIR, 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).
My provider's default installed MTA is exim, so
zypper in postfix (remove exim) 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.
Do NOT use YaST to configure Postfix (your mta), YaST try to fetch the mails from an external server.
The postfix config file is /etc/postfix/main.cf.
The default YaST (openSUSE) configuration is entirely at the end of the file, after all the comments. Here the last time an option is set win.
You can comment out most of the default options, only usefull in more complicated setups. My file holds only this:
mydomain = dodin.org myhostname = kim3.dodin.org myorigin = $mydomain mydestination = $myhostname, localhost.$mydomain, dodin.org, dodin.net, kim3.dodin.org inet_interfaces = localhost
Where my domain is the domain name pointing to the server's IP, kimX is the servers name itself, so myhostname parameter must have the FQDN (Full Qualified Domain Name) of your server.
mydestination must hold all the domain names accepted as mail recipient. The "kimX.$mydomain" is probably not necessary (as it's the same as myhostname), but was added at a moment and as it works, I don't bother removing it :-).
The inet_interface parameter is Localhost by default. On my old config it worked, on the last it didn't anymore, I had to change it for "All" (or may be "all" (all lowcase). Now (April 2014), it's again localhost that works. The only difference I see is than last one was a virtual machine, all others are real hardware.
This is all what you need to send and receive mails from this computer... Think to open ports on the firewall for smtp. smtp is Simplifyed Mail Transport protocol and manage receiving and sending mails.
This uses also clear text passwd sending, wich is not very secure, but most ISP uses only this, so may be the risk is not big. I may use one day secured accounts, but it's much more difficult to setup.
You may want to limit the size of the mails.
message_size_limit = 0 mailbox_size_limit = 0
Here there is no limit. Recently I had problem with users keeping power point slideshows in they mailboxes and I had to make the limit upper. Now with 50Gb home and 1TB data, I don't anymore limit, eventually I can move the mailbox to /data.
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.
#ajouté par jdd, 23 Mai 2010 root: jdd, \root jean.daniel: jdd
You can copy this file from the old install to the new. Do not forget to run "newaliases" to compile this file for postfix. Looks like running also 'postalias /etc/aliases' makes things looks better (remove at least one error message).
On the line "root", adding \root makes the mails to have two destinations, the original root and jdd. If not the mails are not delivered at all for the root account, which is disturbing in debug mode.
To go from root to user to see if you receive mails, do use "su - user". The dash is necessary else you wont see the mails.
You can list the postfix config (without comments) with "postconf". Option -d list defaults values, without opt, list present values and -n list the modified values (very usefull). There are many variable, so filtering through more or less is usefull.
Search google for "using telnet to test postfix" to find tutorials on the subject.
Read the logs (/var/log/mail) and obey what is said there. openSUSE 12.1 needed one more parameter that was exactly described there
"Feb 15 16:21:36 savage-reborn postfix/smtpd: fatal: parameter "smtpd_recipient_restrictions": specify at least one working instance of: check_relay _domains, reject_unauth_destination, reject, defer or defer_if_permit"
Reloads the config, but this is not always suficient. You have sometime to stop then restart postfix
systemctl stop postfix.service systemctl start postfix.service
Last server I configure (April 29, 2014) had openSUSE defaults all over the main.cf file (postconf -n very long) and I couldn't make it work. So I simply copied the old main.cf file and all worked again... here the "postconf -n" result on the working configuration.
s-r:/etc/postfix # postconf -n alias_maps = hash:/etc/aliases, hash:/var/lib/mailman/data/aliases command_directory = /usr/sbin config_directory = /etc/postfix daemon_directory = /usr/lib/postfix data_directory = /var/lib/postfix debug_peer_level = 2 debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5 html_directory = /usr/share/doc/packages/postfix-doc/html inet_interfaces = localhost mail_owner = postfix mail_spool_directory = /var/mail mailq_path = /usr/bin/mailq manpage_directory = /usr/share/man mydestination = $myhostname, localhost.$mydomain, culte.org, asso.culte.org, savage.culte.org, savage-reborn.culte.org mydomain = culte.org myhostname = savage-reborn.culte.org myorigin = $mydomain newaliases_path = /usr/bin/newaliases queue_directory = /var/spool/postfix readme_directory = /usr/share/doc/packages/postfix-doc/README_FILES sample_directory = /usr/share/doc/packages/postfix-doc/samples sendmail_path = /usr/sbin/sendmail setgid_group = maildrop unknown_local_recipient_reject_code = 550