Setting up a Mail server using Roundcube – Part-1 – Centos 7

    Do you want to setup a dedicated mail server for your website, Our mail server depends on three major criteria,

  1. Postfix (SMTP)
  2. Dovecot (IMAP)
  3. Roundcube (Mail Client)
    This article will show how to install and configure the above criteria for setting up a mail server for a domain.

Your personal, business or professional blog website is just a click away!

Postfix:

    Postfix is a mail transfer agent (MTA) that delivers electronic mail across globe. It is also called as an SMTP server. Postifx can be integrated with spamfilters, dovecot and  complex SMTP-level access-policies

    To install postfix in a rpm based machines run the below command,

$ yum install postfix

    The default path of the config files are found under this directory /etc/postfix.

    The main.cf file is the core of your mail server configuration. The default main.cf file lists only a portion of the nearly 300 Postfix parameters. Most Postfix parameters do not need to be changed, but the flexibility is there when it’s required. The path for the main.cf file is /etc/postfix/main.cf

    The next important config file is the master.cf file. The master daemon uses the master.cf file for its configuration information. The master.cf file contains a line for each Postfix service or transport.
   
    Each line has columns that specify how each program should run as part of the overall Postfix system. Most of all the master.cf file can be edited for additional features such as SMTP authentication,etc.,. Since this is a simple mail server setup, we will not working on this file.

    Whenever you made changes to these files the postfix application should be reloaded or restarted.

$ service postfix reload

or

$ service postfix restart

UK Web Hosting

Changes to be done on main.cf file:

    Since we are going to setup a global access mail server to receive mails from external world hence change the inet_interfaces to all from 127.0.0.1

inet_interfaces = all

Add the below lines on your main.cf files,

alias_maps = hash:/etc/aliases myhostname = mail.ljunix.com mynetworks = 127.0.0.0/8,10.0.0.0/8 mydestination = mail.ljunix.com mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all local_recipient_maps = $relocated_maps,$alias_maps,proxy:unix:passwd.byname virtual_alias_maps = hash:/etc/postfix/valias.txt relay_recipient_maps = hash:/etc/postfix/relay_recipients relay_domains = hash:/etc/postfix/relay_domains virtual_mailbox_domains = /etc/postfix/vhosts.txt virtual_mailbox_base = /var/spool/mail virtual_mailbox_maps = hash:/etc/postfix/vmaps.txt virtual_uid_maps = static:1000 virtual_gid_maps = static:1000 virtual_mailbox_lock = dotlock virtual_minimum_uid = 1000 message_size_limit = 20971520 recipient_delimiter = + smtpd_helo_required = yes disable_vrfy_command = yes strict_rfc821_envelopes = yes invalid_hostname_reject_code = 554 multi_recipient_bounce_reject_code = 554 non_fqdn_reject_code = 554 relay_domains_reject_code = 554 unknown_address_reject_code = 554 unknown_client_reject_code = 554 unknown_hostname_reject_code = 554 unknown_local_recipient_reject_code = 554 unknown_relay_recipient_reject_code = 554 unknown_sender_reject_code = 554 unknown_virtual_alias_reject_code = 554 unknown_virtual_mailbox_reject_code = 554 unverified_recipient_reject_code = 554 unverified_sender_reject_code = 554 smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender_access,reject_unknown_sender_domain smtpd_recipient_restrictions = reject_invalid_hostname,reject_unknown_recipient_domain,reject_non_fqdn_recipient,reject_unknown_recipient_domain,permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination,check_recipient_access hash:/etc/postfix/recipient_access smtpd_client_restrictions = check_client_access hash:/etc/postfix/client_access,reject_rbl_client cbl.abuseat.org,reject_rbl_client bl.spamcop.net,reject_rbl_client zen.spamhaus.org smtpd_helo_restrictions = check_helo_access hash:/etc/postfix/helo_access,reject_invalid_hostname

Your myhostname will be your mail server name.

Create the below files that you have mentioned on your main.cf files,

$ touch /etc/postfix/valias.txt $ touch /etc/postfix/relay_recipients $ touch /etc/postfix/relay_domains $ touch /etc/postfix/vhosts.txt $ touch /etc/postfix/vmaps.txt $ touch /etc/postfix/sender_access $ touch /etc/postfix/recipient_access $ touch /etc/postfix/client_access $ touch /etc/postfix/helo_access

Creating .db files:

    You can create db files once adding a new file using postmap command, the same can be used to update the .db files too. Update their .db files on every changes, The reason for using .db files is postfix is able to lookup information in hashes faster than a normal text file.

$ postmap /etc/postfix/valias.txt $ postmap /etc/postfix/relay_recipients $ postmap /etc/postfix/relay_domains $ postmap /etc/postfix/vhosts.txt $ postmap /etc/postfix/vmaps.txt $ postmap /etc/postfix/sender_access $ postmap /etc/postfix/recipient_access $ postmap /etc/postfix/client_access $ postmap /etc/postfix/helo_access

valias.txt Your user emails associated with the username.
relay_recipients Defines the list of valid email addresses for the domain hosted.
relay_domains Domains that has been relayed.
vhosts.txt Domains hosted on this mail server.
vmaps.txt Contains virtual email address and mailbox location.
sender_access Allows particular senders to send mails to your mail server.
recipient_access Used for access control.
client_access Used for access control.
helo_access Used for access control.
    On the above files we will editing two of the files for setting up a simple dedicated mail server for a domain valias.txt and vhosts.txt

    We will be creating an email as jhony@ljunix.com with username jhony. So your valias.txt file will look like as,

$ cat /etc/postfix/valias.txt jhony@ljunix.com jhony

    And your vhost.txt file will be like,

$ cat /etc/postfix/vhosts.txt ljunix.com OK

    Update both files hash files by postmap command,

$ postmap /etc/postfix/valias.txt $ postmap /etc/postfix/vhosts.txt

Create a user:

$ useradd jhony $ passwd jhony Changing password for user test. New password: Retype new password: passwd: all authentication tokens updated successfully.

    Now we have all set on our postfix configuration, we further work on dovecot configuration on the upcoming article Setting up a Mail server using Roundcube – Part-2 – Centos 7

    Feel free to ask if you have any questions.

Leave a comment

Website Powered by WordPress.com.

Up ↑

Design a site like this with WordPress.com
Get started