Mail server HOWTO

Şuraya atla: kullan, ara

The task of setting up a mail server can be seen as complicated because there are many different options and configurations available. Many times there are numerous ways to acheive the same thing. As this page describes many different options, depending on your needs you may decide to use some parts and not use others.

Server

Inbound

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.

POP & IMAP

If you want to fetch mail from more than one mailbox, fetchmail is the tool to use. It will get mail from various servers with various protocols and various people.

First see that fetchmail is installed. Next you need to configure /etc/fetchmailrc. Open it with your favourite editor as root. Each mailbox needs to be configured separately. Things you need to know is:

  • local user id
  • remote server
  • remote user id
  • remote password

Now for each remote mailbox write:

poll remote.example.com
     proto auto
     user "remote_userid"
     pass "remote_password"
     is local_userid

This will put the mail from the mailbox remote_userid@example.com in the mbox for user local_userid Do this for any and all remote mailboxes. See that /etc/fetchmailrc is chmod 700.

Read man fetchmail for more info. Also there is a program fetchmailconf which could be used.

Now you want to do this automatically. As root you type

# rcfetchmail start

See that it automatically starts when booting the machine. This will get the mail every 10 minutes. You can change this by changing FETCHMAIL_POLLING_INTERVAL=600 to any other time interval.

Icon-info.png
Do NOT set this lower than 600 seconds (10 Minutes), as it will load the provider's mail server, unecessarily, and may even be against their Terms of Service

FETCHMAIL_POLLING_INTERVAL and other parameters can be changed either by editing /etc/sysconfig/fetchmail or by using YaST's sysconfig Editor (System -> /etc/sysconfig Editor): choose Network -> Mail -> Fetchmail.

Configure your client to get mail via mbox

SMTP

You can get mail directly sent to your server. For this you need several things:

  • Domain name
  • Fixed IP address or Dynamic DNS
  • Correct MX records

If you have a Dynamic DNS, seriously reconsider if you want this for your regular email. If you do: get a fixed DNS.

First see that postfix is running. This can be done by a telnet session:

# telnet localhost 25Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 example.com ESMTP Postfix
  • Next see that the outside world is able to connect to port 25 by opening this in your firewall with YaST and in your router. test it with This site.
  • Edit /etc/postfix/main.cf and read it first before you do any changes. The changes should be done at the end.Three things should be added and/or changed:
myhostname = hostname.example.com
mydomain = example.com
mydestination = $myhostname, $mydomain, localhost.$mydomain

Leave the rest alone

Now restart postfix with rcpostfix restart. You will now be able to recieve mail for logins on example.com Configure your client to get mail via mbox

Aliasses

Mail will be put in /var/spool/mail/user_login. Most of the time you might want to receive mail under something else then your login. If your login is user, you probably would like an emailaddress like firstname.lastname@example.com You then link an alias to user with the name firstname.lastname This can be done by editing /etc/aliases. Add the following at the end of the file:

firstname.lastname:    user_login

You will see some there already. If you want a generic address like sales@example.com and that to be received by several people, add the following line:

sales:                 user_1, \user_2, \user_3

After each addition, you need to run newaliases and rcpostfix restart.

Configure your client to get mail via mbox

Outgoing

This will be about all the mail that goes from you to the Internet.

Pointing your Email program

To be able to send your email to others, you need to hand over your mail to a server at your provider. Most of the time this will be an SMTP server. Sometimes you need a login and password. Read the documentation of your email-client on how to configure this

Sending mail via the provider for all

You can get mail directly send to your server. Standard you can start sending email directly the moment postfix is running. Just point your email clients SMTP to localhost. Some emaillists require you to edit the envelop_from to yes. See your email clients manual on how to do this.

Need info on how to do this in postfix

Sometimes you are forced to use your providers server or some servers will not accept your mail directly. In that case edit in /etc/postfix/main.cf the line that starts with relayhost. e.g.:

relayhost = smtp.exmaple.net

Restart postfix with rcpostfix restart and configure your email client to point the SMTP server to localhost.

Sending mail with your own domain

You can send mail directly send from your server if you have an own domain. For this you need several things:

   * Domain name
   * Fixed IP address or Dynamic DNS
   * Correct MX records 

If you have a Dynamic DNS, seriously reconsider if you want this for your regular email. If you do: get a fixed DNS. Some SMTP servers look up the reversed DNS settings and these settings are only possible if you have a fixed DNS. First see that postfix is running. This can be done by a telnet session:

# telnet localhost 25Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 example.com ESMTP Postfix
  • Next see that the outside world is able to connect to port 25 by opening this in your firewall with YaST and in your router. test it with this site.
  • Edit /etc/postfix/main.cf and read it first before you do any changes. The changes should be done at the end.Three things should be added and/or changed:
myhostname = hostname.example.com
mydomain = example.com
mydestination = $myhostname, $mydomain, localhost.$mydomain

Leave the rest alone

Now restart postfix with rcpostfix restart. You will now be able to send mail with example.co.m Configure your client send via localhost

Filtering

Spam filtering, virus filtering, ... Adding signatures, headers and what not and removing binaries.

Spam

Virus

Client

Pointing your Email program

  • To be able to read mail from your provider, you need to know where it. If you get mail from your provider, you will most likely use IMAP or POP3. With IMAP the mail stays with the provider, with POP3, you take the mail from your provider to your PC.

Read the documentation of your email-client on how to configure this

  • Local mail will as a standard come in /var/spool/mail/user_login, so mail handled with postfix will end up at that location.

The protocol is mbox, which will be usable by many mail programs in SUSE. To test this, you can run the following command:

# mailx user_login
Subject: test or whatever
Something you like to write
.

Do not forget to add the last . (dot). To see if the mail has arrived, use your mailclient or just type mail (q to quit)

Read the documentation of your email-client on how to configure this.


Filtering

Mainly procmail

Extras

All other things that can be done with ail that is not covered in the above

Webmail

Squirrelmail

Bu makalenin geliştirilmeye ihtiyacı vardır. Eğer yardım edebilirseniz lütfen OpenSUSE Style Guide içerisinde yapın.

Eger yapacak birşeyler arıyorsanız articles that need expanding