 Hello everybody! Watch this video to find out how to install and configure a postfix mail server with Dial Cod. How to configure the mail server to prevent your mails from falling into the spam folder, how to add DNS entries such as SPF, DKIM and DMorg. Creating a mail server on Linux-based machines could be one of the most important things that every system administrator should do. If this is the first time you configure your server, you're going to face a lot of aspects that have to be considered during setup. After this video, I'll take you through the initial server configuration. We'll discover how to install a postfix mail agent and a DovCod mail server and how to configure them for your emails to circulate properly. Postfix is a free and open-source MTA, which stands for Mail Transfer Agent, that can be used to route and deliver electronic mail on a Linux system. DovCod is a mail-deliver agent created primarily with security in mind. I'll show you how to configure it as an IMAP or POP3 server. In our channel and blog, you will find solutions to any problem from installing an operating system or configuring it to fixing possible bugs and errors or optimizing mobile gadgets. Our specialists will answer any questions you ask in your comments, under the videos or articles. To begin the installation, you'll need to properly configure the Linux Ubuntu server with a fully qualified domain name or FQDN for short. On the server, you need to add a non-root user but with pseudo-privileges and open corresponding ports in your network. I already have a server with required settings and its ports are configured properly, so the only thing left to do is to add a user and start installing mail applications. To add a user, open the terminal by pressing the key shortcut Ctrl Alt T and run this command. Set a new password for this user and leave other values without changes. You can specify any additional information if you need to. Now you have a new user account with standard privileges. However, sometimes you may have to perform administrative tasks as a root user. To avoid having to sign out of your regular account and then sign into a root user account, you can configure the so-called superuser or root privileges for your regular user account. This will let you run commands with administrative privileges by just placing the word pseudo before the command. To add privileges, you need to add a new user into the pseudo-system group by running this command. The next thing to do is to set a true domain name for your server. For this purpose, there is a special command – hostname CTL. After that, you need to add mx and a records for the domain in the DNS control panel. These records will show to the other mail agents that your domain is in charge of delivering electronic mail. Open the DNS control panel and add these records. Here you need to specify your server's public IP address. Now you can begin the installation of a Postfix mail agent. Here is the command you need to use. In the Postfix configuration window that opens, click OK. After that, the system will suggest you to choose mail configuration type, select Internet Site and press Enter. In the next window, type the domain name to be used when sending electronic mail. After a Postfix is installed, it will start automatically and create a configuration file. You can check Postfix version and service status by using the following commands. If you need to change the configuration, use this one. And click OK. Here select Internet Site and press Enter. In the next window, type the domain name to be used when sending electronic mail. Then add the mail recipient. Specify other destinations to accept mail. Force Synchronous updates on mail queue – no. I will leave local network settings without changes. Mailbox size limit – 0. Mail address extension character – plus. Internet protocols to use – all. Noveless check – if your mail server is connected to port 25 by running this command. The result displayed by the system indicates that the connection has been established successfully. To close the connection, type QUIT. Also, you can use a mail application to test the mail service. However, it should be installed first, so run the installation command. Here is the command to use. Specify the email address to send your mail to, subject and contents. And then press CTRL D to send. As you can see, the mail service works and the email was delivered, but it ended up in the spam folder. I'm going to show you what settings should be changed to prevent emails from being classified as spam. After sending the first email, the program will create a file with the user's name in the BAR mail folder. In this file, all incoming and outgoing mail will be recorded. This recording format is known as MBOX. To use the mail-deer format, which divides emails to separate files which are then moved between the directories depending on the user's actions, you need to make some changes to the configuration file. Add this line. Or run this command. In this case, mail will be stored in separate files and can be found by this path. As a result, the mail server is running, you can send and receive mail, but it can hardly do without an opportunity to send mail by SMTP. This protocol is already supported in Postfix, but it has no authentication by default. To add authentication support, you should use Dovcott. As a bonus, you'll get the opportunity to view your mail by POP3 and IMAP protocols. First of all, you need to install the Dovcott service itself. And here is the command to use. After the installation is over, it is recommended to restart the Dovcott service. To configure Dovcott, you should edit the configuration file. To open it, you need one more command. You can choose which protocol to use. It could be POP3, POP3S, secure POP3, IMAP or IMAPS, which is secure IMAP. IMAPS and POP3S are more secure than conventional IMAP and POP3, since they use SSL encryption for their connections. As soon as you have chosen a protocol to use, correct the next line in the file Dovcott.conf.add or edit this line. Press Ctrl-X and then Yes to save it. Enter. Now let's check how POP3 works. Go to a checkup service, enter the data, and click to start the test. As you can see, the test is successful. Alright, we have configured the mail service. Now we need to make sure that the mail doesn't end up in the spam folder. And for that purpose, you should add a few more DNS records. Open the DNS control panel, add SPF, DMARC and DKIM records. To have SPF and DMARC running, all you need is to add their DNS records. But for DKIM to work, it has to be installed in the server. Domain keys identified mail or DKIM for short is an email authentication method designed to detect forged sender addresses in email, known as email spoofing. DKIM enables the user to check if an email was actually sent from the stated domain. And here is the command you need to install the package. Then start it and add it to automatic setup. After that, you should create a certificate with the help of OpenDKIM GenKey. Create a directory for keys using this command. And use another command to generate a key. Here you need to specify your service domain name. In the folder ETC OpenDKIM, two files should appear, with extensions, private, a private key and TXT, a TXT record. Now let's configure DNS. View the contents of the TXT file, copy the contents, switch to DNS control panel and create a TXT record. Assign a name to it and paste the TXT file contents, where mail is selected to name and here is the public key. Now let's make changes to the configuration file. Here you need to command and add a few lines. Add your domain to trusted hosts. Add the domain Ctrl-X, Yes, and Press Enter. Give the path to the key Ctrl-X, Yes, and Press Enter. Now that the record is added, let's check it. Open a D-KIM checkup service in the browser. Type the domain in this field, add the selector name in the other field. As you can see, the service has found my D-KIM record. The record is added. For additional fine tuning, adding trusted hosts, domains, etc., you will have to open the configuration file and add extra settings. Now let's test mail sending again. Ctrl-D. As you can see, the email arrived and this time it was not dumped into the spam folder. Let's reply to this email. Now the mail service works properly. Alright, so we have installed and configured postfix and dovcott, checked how that mail service works and added corresponding DNS records. For more convenient work, you can add a MySQL storage server and a mail client. For example, RoundCube. But that is all for now. Hopefully, this video was useful. Remember to click the Like button and subscribe to our channel. Leave comments to ask questions. Thank you for watching. Good luck.