How to configure postfix and dovecot with roundcube in centos 7 VPS?(Part 1) - CloudMinister

How to configure postfix and dovecot with roundcube in centos 7 VPS?(Part 1)

Mail Server

Popularly also known as ‘email server’ that help to send and receive mail from client to server, fully manages VPS  server to different servers by using different protocols like SMTP(Simple Mail Transfer Protocol) that is used to send mails and POP3 or IMAP that is used to receive mails.

In this configuration we use Postfix as an SMTP protocol for sending mail and Dovecot as an IMAP or POP3 for receiving mail on email client from server, also use round cube for web based IMAP client.

Prerequisite

1. Centos 7 VPS

2.Domain Name

3. Postfix

4.Dovecot

5. Roundcube

Configure Centos 7 VPS

In Centos 7 VPS, enable SSH and HTTP port.

After that open machine with SSH in local system and Disabled the Se Linux by using the following command:

    # vi /etc/selinux/config

In place of SELINUX =Enforcing replace Enforcing with Disabled and save the configuration file with :wq.

Configure Domain Name 

Configure your domain name by creating new MX record in management console of your domain name, also create A record with Name ‘mail’ in the same domain.

You can configure it by using the following steps:
1. Open your Domain Name provider website and login with your own credentials.

2.Go inside your Domain Name and click on manage DNS, now after that give IP address of your Linux vps hosting  in Target field.

3. Now Create two records one is the A record by filing the following fields like:

Name    Type        TTL        Target

WWW      A        300        IP_Address

MAIL        A        300        IP_Address
4. After creating A record now create MX record by filling the following fields like:

5.Name Type     TTL        Target           

  MX        3600        mail.your_domain.com

  Priority:10
Save the configuration and exit from the settings.

Configure Postfix

Postfix is allowing server to send mail to email client and server by using SMTP protocol.

Install Postfix

First install postfix by using yum command:

    # yum -y install postfix

Edit the configuration file /etc/postfix/main.cf and set the value as follows:

    # vi /etc/postfix/main.cf (Open File with the vi editor)

myhostname = mail.securitylevel.ga (Enter your host.with_domain.com)

mydomain = securitylevel.ga (Enter your_domain.com)

myorigin = $mydomain

inet_interfaces = all

mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

mynetworks = 192.168.1.0/24, 127.0.0.0/8 (Enter your own system IP address) not compulsory

home_mailbox = Maildir/

Uncomment ‘#’ from the above lines.

Once all the value has been set, after that set application to start during  system boot and start the service by using the following command:

    # chkconfig postfix on

    # service postfix start

Testing Postfix

To check if everything is working properly or not, you can send an email by type the following command from console: 

    # telnet localhost smtp

If telnet command not work then first download telnet with the following command:

    # yum -y install telnet

Before testing postfix create new user with help of following command:

    # useradd admin

    # passwd admin

Give New password and confirm password. 

After then give several inputs to send mail:
→ ehlo localhost

→ mail from: admin@securitylevel.ga(username@domain.com)

→ rcpt to: admin@securitylevel.ga(username@domain.com)

→ data

→ New Mail!

→ .

→ quit

To check if the mail has been received or not, go inside the following directory i.e. /home/username/Maildir/new/

    # cd /home/admin/Maildir/new/

    # ll

    # cat XXX.XXX.XXX.mail.securitylevel.ga(Domain Name)

If the mail received by the system then mail server is working properly.

Configure Dovecot

While Postfix acts as a Mail Transfer Agent(MTA)only, in order to retrieve emails using modern tools you need to enable IMAP/POP3 protocols. Dovecot is an application that acts as a secure IMAP and POP3 server.

Install Dovecot

By using yum command you can install Dovecot:

    # yum install dovecot

Edit the configuration file /etc/dovecot/dovecot.conf to enable the needed protocols.

    # vi /etc/dovecot/dovecot.conf

Uncomment ‘#’ from the following lines in this file:

→  protocols = imap pop3 lmtp

Then you need to specify the mail location by editing the file /etc/dovecot/conf.d/10-mail.conf.

    # vi /etc/dovecot/conf.d/10-mail.conf

→ mail_location = maildir:~/Maildir

Edit the file /etc/dovecot/conf.d/10-auth.conf and set the following values:

    # vi /etc/dovecot/conf.d/10-auth.conf

→ disable_plaintext_auth = no

→ auth_mechanisms = plain login

Last file to edit /etc/dovecot/conf.d/10-master.conf.

    # vi /etc/dovecot/conf.d/10-master.conf

unix_listener auth-userdb {

    #mode = 0600

    user = postfix

    group = postfix

}

Note: After done editing in each file save with :wq in vi editor.

Also set Dovecot to start at system boot and start the service.

    # chkconfig dovecot on

    # service dovecot start

Testing Dovecot

To check if everything is working properly or not, you can receive an email by type the following command from console:

    # telnet localhost pop3

After that give several input to retrieve mails.

→ user admin (use your_user_name)

→ pass password (use your_password)

→ list

→ retr 1

Now message is shown here and after checking the output quit the screen with:

→ quit

NEXT

Learn how to scale, manage, and optimize your applications with a SLB. Read our solution brief "Get More from Your Enterprise Network".

DOWNLOAD SOLUTION BRIEF

Get started with CloudMinister Today