Create your own mail server - how it works
If you want to create your own mail server, a number of steps are necessary. In this practical tip, we will show you how to proceed.
Create your own mail server - preparations
- Under Debian 7 XFCE, first click on the network icon in the top right corner and select "Connection information".
- Slide this window to the side and right-click the icon again. Then select "Edit connections".
- There you select the connection and click on "Edit". Then switch to the "IPv4 Settings" tab.
- To ensure that the mail server always has the same IP address, set the "Method" to "Manual" and enter the IP address from the window of the connection information under "Address".
- Enter the "Subnet mask" from the other window into the "Netmask" field, while the "Default route" into the "Gateway" field and the IP from "Primary DNS" into the "DNS server" field.
- Save by clicking on "Save".
Create your own mail server - install the mail server
- Now switch to "Accessories"> "Terminal" and get administrator rights with "su" and the administrator password.
- Then enter the command "apt-get install exim4 dpkg-reconfigure exim4-config" to install the mail server and confirm with [Enter].
- When setting up, select the option "Send via sending center (Smarthost); Receive with SMTP or Fetchmail".
- Leave the "System e-mail name" field empty and then click on.
- Enter the "Subnet mask" from the other window into the "Netmask" field, while the "Default route" into the "Gateway" field and the IP from "Primary DNS" into the "DNS server" field.
- Under "IP addresses at which incoming SMTP connections are expected" change the line as follows: 127.0.0.1; :: 1; 192.168.178.39
- Also leave the field "Other destinations for which emails are to be accepted" empty.
- Enter "192.168.178.0/24" for "Computers for which e-mails are to be forwarded (relay)".
- You must enter the SMTP address of your provider in the field "IP address or computer name of the sending center for outgoing e-mails".
- Answer all other questions with "No".
- The setup is then complete. Switch back to the terminal and enter "nano /etc/exim4/exim4.conf.localmacros" so that the SMTP login is encrypted.
Create your own mail server - final settings
- Open the terminal again and install the inbox server Dovecot with "apt-get install dovecot-imapd".
- With the command "nano /etc/dovecot/conf.d/10-mail.conf" you open the configuration file. Scroll down to "mail_location" and change the line as follows: mail_location = mbox: ~ / mail: LAYOUT = maildir ++: INBOX = / var / mail /% u: CONTROL = ~ / mail / control
- Save the changes with [CTRL] + [O].
- In order for the emails to be retrieved from the server, you need Fetchmail. You can install it with "apt-get install fetchmail procmail".
- Then each user must create a file called "fetchmailrc" in the respective home directory.
- This file must be structured as follows: poll Protocol User Is Pass Folder INBOX Ssl Mda "formail –c >> - / mail / .INBOX" Keep
- Under "Poll" you enter the protocol and the server of your provider, with "User" and "Pass" your username and the associated password are entered. Then it is defined where the mails are to be stored and that they should be retrieved safely.
- In order for the mails to be loaded automatically, enter "crontab –e" into the terminal and then the command: 0, 10, 20, 30, 40, 50 * * * * / usr / bin / fetchmail –s
This practical tip is based on Linux Debian 7 XFCE. If you want to rent a mail server, we have summarized the three cheapest providers for you.