Skip to content
Step by Step Internet 馃寪 Guides for learning to surf the Net

Raspberry Pi Projects How to create and configure an email server with Raspberry Pi fast and easy? Step by step guide

Although there are thousands of email providers, large companies prefer their own server and have a secure service, more private, and completely customizable.

Since this project requires a server turned on throughout the year, it is better if you use a Raspberry Pi computer, It consumes less energy and requires minimal maintenance.

In this article you will know everything that is required to know to set up your first custom mail service on a Raspberry Pi. In addition, you will know the pros and cons of having this service.

What do I need to create and configure an email server on my Raspberry Pi?

How to register a domain fast and easy

In this section we will show you what is required to do a correct installation of a mail server, using a Raspberry Pi equipment:

  • Register a domain: It seems basic, but if you do not have a registered domain, in short, you will not be able to move forward with the installation of your mail server.
  • Raspberry Pi OS: It is important that you start the installation with the official operating system of Raspberry Pi computers, thus avoiding major headaches due to incompatibility in the configurations.
  • Stable internet connection: it is better if the connection is made with dedicated internet and fiber optic service, so there will be no bumps in data transmission.
  • Electricity supply: When you don’t have the official Raspberry feeder on hand, it’s best to have a high-quality feeder, you could even go for a new official feeder.
  • SSH client: so we can access the Raspberry computer externally, we cannot install an operating system that offers assistance through a desktop.

What should I consider before deciding if it is profitable to create a private mail server?

There are two possible scenarios in which investing time and resources in your own server is profitable:

  • Learning mode: If you are a technology enthusiast, and just starting to program, then the Raspberry team shows you an accessible and easier way to master than the paid alternatives. In the learning process, we can damage a computer and spoil the whole project, so you will see that replacing a Raspberry is cheaper.
  • Have full control: If data protection is a real problem for your business, then having your own mail server is the most accessible solution. This way you avoid investing resources in companies and developers that offer the same services for you, but at a high cost. In these cases, it is better to have a staff in charge of this work.

Pros and cons of a private email server Is it worth doing the project for personal use?

If you have doubts about when to create your own mail server, then you should review this list of advantages and disadvantages of having this service and using it on a Raspberry Pi computer:

Advantages

  • Only you and who you authorize will have access to emails and data
  • Is a safer option.
  • It’s more easy to guarantee access ways, inside and outside the internal network.
  • You will have a 100% customizable service.
  • Accounts with greater programming options.
  • The size of the files it is no longer limiting.
  • Can configure any device to have access to emails.
  • Can create as many addresses and extensions as you want.

Disadvantages

  • From the beginning, a greater investment in hardware is required.
  • It requires a greater investment in terms of qualified personnel.
  • It requires a constant review and update of equipment and programs.
  • If the job is not done well, commercial emails can classify your messages as “SPAM”.
  • It requires the development of an interface that is worthy for any type of end user.

Learn step by step how to create a private email server with a Raspberry Pi from scratch

To follow these steps, a permanent internet connection is required, preferably a dedicated internet service that allows constant reviews and updates of the different trays of your personalized mail.

Go for it:

IP adress

Commands to know IP address in Raspberry PI

This address needs to be static and private, always on your local network to have constant access to your incoming and outgoing emails:

  • Known what is the momentary static direction.
  • Select the internet symbol on Raspberry Pi OS and write down the direction you can see.
  • Press the right button and select “Wifi Settings”.
  • Choose the option “Eth0”.
  • Write the first three sequences of the IP address.
  • In the remaining field, write the rest of the sequence.
  • Reboot the device Raspberry Pi.

Install a mailserver suite

Official website for downloading Citadel

For this step-by-step, use the Citadel / UX client as the mailserver program and continue with the procedures to follow:

  • Update packages pre-installed.
  • Write the command line: sudo apt-get update.
  • Later, write: sudo apt-get upgrade.
  • The program will detect that IPv6 is not available, you must write: sudo modprobe ipv6.
  • Now, install Citadel with this command: sudo apt-get install citadel-suite.

Install a mail server

Citadel interface on Raspberry PI

You can also use a Citadel server, so there will be no errors or glitches during the installation and general operation of the server:

  • Start with the command: sudo service citadel start.
  • Write in your browser the static and private address of your Raspberry.
  • Before using IPv6, you must use IPv4: sudo /usr/lib/citadel-server/setup.
  • You must go into the Citadel settings, for that, enter as administrator.
  • Keep username as “Citadel” and place as direction “0.0.0.0”.
  • Citadel I know will restart.

Connect the Citadel server to the Raspberry Pi

Password and username to connect to Citadel

You should already be able to see a panel to put administrator username and password when you put the IP address in the browser:

  • Search the option Administration.
  • In the section “Global configuration”, check the box “Edit site-wide configuration”.
  • Mark on the menu “SMTP”.
  • You’ll see three ports that are used by Citadel.
  • Write down these three ports then configure the router.

Connect a domain name

The first that you must have on a DNS server. You will put the name and you must connect it with Citadel.

Use as domain name DNS Host (A):

  • Enter the domain name in the browser.
  • Should open directly to server of mail Citadel.
  • In the section of “Administration”, Choose “Domain names and Internet mail configuration”.
  • Put the domain name in “Local host aliases”.
  • Go back to “Administration” and in the section “Edit site-wide configuration” put the domain name as “Full qualified domain name”.
  • Reboot Citadel.

Until this step, your mail installed on this server can now operate without any problem.

We show you how to set up your own mailserver with a Raspberry Pi using Courier from scratch

One time have a registered domain, you can now start installing a mail service with Courier in you Raspberry.

It is a simple client to configure, at least simpler than most similar clients:

First steps

Courier mail server official website

  • Run this command, assuming that the operating system it is based on Debian or Ubuntu: sudo apt-get install courier-mta courier-imap.
  • This will install the server and the IMAP environment.
  • tell her “Yes” when it asks if you want to prepare the directories for the web interface.
  • Now, you already have a mail server with Courier.
  • Set the server name: echo minombrededomino >> /etc/courier/locals.
  • Later, write the line makealiases.
  • I know requires superuser permission (root) the steps above.
  • This will allow emails from other customers, such as Gmail, can enter the inboxes without being rejected.

Authentication in SMTP

The SMT servers also require authentication that you must configure with the following steps.

It is a way to prevent anyone with access to the server from sending emails:

  • Find and open the file: /etc/courier/esmtpd.
  • Require superuser permissions to do so.
  • In the variable “AUTH_REQUIRED”, value must be “1”.
  • Y in the variable “ESMTP_AUTH”, must be place value “LOGIN”.
  • Now you must restart the server.
  • Writes “sudo courier restart”.

Configure the mail client

Courier mail server interface

So far, We have only managed to get Courier to receive emails only for accounts that exist on the server.

A final configuration is required and you need to know the server account:

  • Write the command “whoami” to know the server account.
  • Should be put some parameters.
  • IMAP: with the port 143, without SSL and with an unencrypted password.
  • SMTP: with the port 25, without SSL, the password should also not be encrypted.
  • So much the user and the password are the same as the server.

When you do the above steps, you can now send and receive emails from your computer, tablet or smartphone when you join an email client that allows you to configure the account with the parameters of IMAP Y SMTP.

More settings

Up to this level, we managed to create a mail server, But only with an account. In addition, the security level is minimal.

We leave a list of the following you should do:

  • Improve security: it requires a filter against spam emails and making SLL connections to achieve greater protection of passwords.
  • Achieve your own interface: Although there are hundreds of free clients that you can use, you can only guarantee a good security of the service when you develop even the user interface that will use the mail.
  • More email accounts: later, you will be able to create new email accounts for more users. You can also manage more than one domain, when you want to differentiate the tasks in each area.