Postfix

From Mandriva Community Wiki

Jump to: navigation, search


Local mail enables users of a single computer to exchange mails among themselves or even outside.

Even if you’re the only user of your computer, you may need a local mail account because some system services (like at, batch, crond, anacron and msec) try to email the superuser or the normal users: it can be useful to read these messages.

This page has been written for Mandriva Linux 2009 Spring. You're welcome to update it if needed and change this paragraph.

Contents

Local mail

How does Unix/Linux mail works?

With Linux and Unix, each users has a local mailbox: it’s a simple text file in /var/spool/mail/.

With Mandriva Linux, the software in charge of mail distribution, sending and reception is Postfix.

We’ll see here local mail exchange, i.e. between one computer accounts. For outside mail, please see the section about Postfix configuration for Internet access below.

Installation and configuration

Packages installation

In the panel (usually at the bottom of your screen) click on Configure your computer

Then on Software management → Image:Drakrpm-icon.png Install & Remove Software. In the left rolling list choose "All". Then look for postfix and webmin, check their boxes and confirm by the "OK" button.

What to configure?

Local mail is correctly configured by default with the only exception of root (superuser)’s mail. root mustn’t receive mail: its mails have to be redirected towards the computer’s real administrator’s simple user account. This is because the the mails it receives are usually important and sometimes urgent (many applications expect the messages sent to root to be read regularly), whereas a system administrator may very well don’t connect as root during a long period during which he will by contrast connect maybe every day as simple user.

Configuring root’s mailbox

Enter webmin, there choose "Servers".

then "Postfix Mail Server"
then "Mail Aliases"
then "root"
then fill the 1st field "Email address" with your login name.
If you want several users to receive the mails sent to root, fill the following "Email address" fields.

Let’s check

If you don’t trust Mandriva or yourself that much, you can check. Open 2 consoles (In KDE: Menu → tools → Konsole) and in both type su to become root. You’ll be asked for the root’s password. Then, in one console, type:

Image:Konsole.png
[root@computer ~]# tail -f /var/log/syslog

The grep command can filter the messages regarding you. Don’t worry if you can’t see anything so far.

In the second console, type:

Image:Konsole.png
[root@computer ~]# mail root

then type "test" as subject, <Enter> , "Hello me!" and at last <Ctrl+D> .

Pieces of information scrolled in the other console: control that the mail has been correctly forwarded (the final recipient’s address must appear.) If there is a problem, stop and restart Postfix from the bottom of the "Postfix mail server" page of Webmin mentionned above, and look at what appear in the 1st console at that time.

Configure security if Thunderbird is used

With Thunderbird, you must first add your user in the mail group, because Thunderbird has less locking modes than Kmail.

For this:

  • Use Mandriva Linux control center Image:Userdrake-icon.png Userdrake from the panel: Configure your computer → System

then Manage users on system

  • Select your user. (In our example, my user name is "I", and my login name is "my_login_name".)

Then click on "Edit".

Choose the thumbnail Groups, check the mail group’s box.

Caution !

This has a consequence on the system security: your user has in principle the right to read, modify, add and delete any local message, even if not meant for him: operation to ban on a computer devoted to be a mail server. To avoid this problem, be careful that the users mailboxes in /var/spool/mail (files whose nam is identical to the user login ID) grant the read and write permissions only to their owner (-rw-------).

Image:Konsole.png
[root@computer ~]# cd /var/spool/mail && chmod 600 ./*
For this, let’s create in Image:drakperm-icon.png drakperm or MSEC a personalised permission rule for /var/spool/mail/*.

In Mandriva Linux control center → security → Configure system security, permissions and audit,

click on the thumbnail "Permissions".

Click on the button "Add a rule".

Fill the form with File:/var/spool/mail/* , User: current, Group: current, Permissions: 600. Validate by "OK".

On the line beginning by "/var/spool/mail/*", check the box.

Close the window. At the question "Do you want to save changes before closing?", click on "Save". Close Mandriva Linux control center.

  • For your changes to be taken into account, you have to close your Mandriva session and login again, but you can do it later if you wish (Remember: if you forget, your system is at risk.)

Configure Thunderbird to read and send local mails

Then create an account of Movemail type. Open Thunderbird from the Application launcher menu → Internet → Mozilla Thunderbird mail news.

In Thunderbird Edit → Account settings… → Add account…,

choose "Email account", then click on "Next",

In the field "Your name", write your login name (in our example: my_login_name) and, as email address, your login name followed by @localhost.

Click on "Next". Choose "pop"; as "Incoming server", write localhost, choose if you want the local mails to be received in the default inbox or in a special one to be created (I recommend the latter, since your computer daemons may send you very many mails.). Click on "Next". As "Incoming user name", write your login name.

As "Account name", write the name you want to give to this Thunderbird account. We named it according to its address: my_login_name@localhost.

On the next page, check everything is OK and click on "Finish". Then click on OK.

Since Thunderbird don’t allow the direct creation of accounts of type Movemail any more, we’ve just created an account of type "Pop", but it won’t work as is. Thus close Thunderbird. Open Dolphin (or your file manager), i.e. the house called "Home" in your desktop. In Dolphin → View, check the box "Show hidden files" and go to the file
/home/my_login_name/.thunderbird/<compte>.default/prefs.js where "my_login_name" has to be replaced by yours, and <compte> is usually a meaningless alphanumerical string. Open this file in a text editor by double-clicking on it. It’s supposed to be your file, so you have read and write permissions for it. In this file, look for the line
user_pref("mail.server.server<no.>.name", "my_login_name@localhost");
where "<no.>" is a number. In Kwrite menu: if you choose Edit → Find, a "Find" field opens at the bottom of the window. There type "localhost" then the Enter key and this will most probably give you the good line. If not, press Enter as many time as necessary. Below the line you’ve found, replace the line

  • user_pref("mail.server.server<no.>.type", "pop3");

by

  • user_pref("mail.server.server<no.>.type", "movemail");


Save your file and close your text editor.

  • Reopen Thunderbird.
  • In Thunderbird main window, click on "Get mail" and check you’ve received, in the inbox you chose, the "test" mail described above.

To send messages, you need a 'localhost' SMTP ("Sendmail transfer protocol") account:

  • In Thunderbird, click on Edit → Account settings…
  • At the bottom of the accounts list, select Outgoing server (SMTP)
  • then on the right upper part of the window, click on Add….

In the opening window, as "Description" type for instance local mail; as "Server name", type localhost; as "User name", type your login name.

Validate. In Thunderbird "Account settings" window’s account list, click on my_login_name@localhost (or whatever name you’ve given to your local mail accounts), then on the right part of the window (this account settings), in the "Outgoing server (SMTP)" rolling list, choose "local host".

If you have frequent crond tasks (crond is a scheduler daemon) which send you many mails, your mailbox may be quickly cluttered. Remember then that Thunderbird enables you to make specialised sub-directories for some types of messages inside the local mail directory.
You can for instance create one for crond’s mails, and create a message filter which will send automatically those messages in this sub-directory. In the inbox will only stay the other messages, less numerous, that you can also, if you wish, have sent in sereral sub-directories.

Internet access

I invite you to translate this part from French: [1]

Personal tools
In other languages
Looking for a job?