Postfix configure
see also http://en.opensuse.org/Mail_server_HOWTO
Postfix
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.
What I need and try to verify
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 as of June 10, 2011, I use smtp (sending mail) only for webmail - no relay.
I then need to be able to send mail from my local (home) desktop/laptop to the server, then using the server as relay send these mail to the whole Internet (this don't work - yet).
Sending and receiving locally
My last install, in 2013, is on a virtual server and so it's a brand new openSUSE original install, so postfix and mailx are default.
At this moment, I have only ssh access to the server, so I need a CLI (Command Line Interface) mail client. I use mailx (so mail jdd from root send a mail to the jdd account.
So, install postfix and mailx if it's not default. AFAIR, the local mailing works out of the box. Try it. The above command (mail jdd) asks for a subject, then a content. You send the mail typing Control D (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.
Using more, configuring Postfix
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, kim2 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 "kim2.$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". Now (April 2014), it's again localhost that works. The only difference I see is than last one was a virtual machine, all others areal 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.
Memory limits
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.
See the Debug part of this page.
MX
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.
Alias
In /etc/aliases
#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).
Debug
Attach:debug_with_telnet.pdf Δ (http://articles.slicehost.com/2008/8/6/postfix-using-telnet-to-test-postfix)
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[18102]: fatal: parameter "smtpd_recipient_restrictions": specify at least one working instance of: check_relay _domains, reject_unauth_destination, reject, defer or defer_if_permit"
postfix reload
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