In this guide, we’ll walk through the steps to set up a complete mail server on CentOS using Postfix for SMTP, Dovecot for POP3 and IMAP, and SquirrelMail as the webmail client. By following these steps, you’ll be able to send and receive emails using your own mail server
- Check IP Configuration:
ifconfig
- Use to check the IP configuration of your system.
2. Set the Hostname:
- Set the hostname of your machine using the following command:
sudo hostnamectl set-hostname yourhostname.local
Add hostname entries in /etc/hosts
file:
vim /etc/hosts
Add the following:
youripaddress local.yourhostname.local local
3. Disable SELinux:
- Check the SELinux status and disable it if necessary:
sudo getenforce
sudo setenforce 0
4. Install EPEL Repository:
- Install the EPEL repository to access additional packages:
sudo yum install -y epel-release
5. Configure Firewall:
- Allow Apache default port 80 through your firewall/router:
sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --reload
6. Install and Configure Postfix:
- Install Postfix package:
sudo yum install postfix -y
- Edit
/etc/postfix/main.cf
file to configure Postfix.
nano /etc/postfix/main.cf
make the given changes
## Line no 77 - Uncomment and set your mail server FQDN ##
myhostname = local.yourhostname.local
## Line 85 - Uncomment and Set domain name ##
mydomain = yourdomainname.local
## Line 101 - Uncomment ##
myorigin = $mydomain
## Line 115 - Uncomment and Set ipv4 ##
inet_interfaces = all
## Line 121 - Change to all ##
inet_protocols = all
## Line 166 - Comment ##
mydestination = $myhostname, localhost.$mydomain, localhost,
## Line 167 - Uncomment ##
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
## Line 266 - Uncomment and add IP range ##
mynetworks = youripaddress.0/24, 127.0.0.0/8
## Line 421 - Uncomment ##
home_mailbox = Maildir/
save the file and exit.
7.Start/restart Postfix service now:
systemctl restart postfix
systemctl enable postfix
systemctl status postfix
8. Install and Configure Dovecot:
- Install Dovecot package:
yum install -y dovecot
Configure Dovecot:
nano /etc/dovecot/dovecot.conf
Edit the following
## Line 24 - umcomment ##
protocols = imap pop3 lmtp
Edit file /etc/dovecot/conf.d/10-mail.conf file
nano /etc/dovecot/conf.d/10-mail.conf
Edit the following
## Line 24 - uncomment ##
mail_location = maildir:~/Maildir
Edit /etc/dovecot/conf.d/10-auth.conf
nano /etc/dovecot/conf.d/10-auth.conf
Edit the following
## line 10 - uncomment##
disable_plaintext_auth = yes
## Line 100 - Add the word: "login" ##
auth_mechanisms = plain login
Edit file /etc/dovecot/conf.d/10-master.conf
nano /etc/dovecot/conf.d/10-master.conf
Edit the following
## Line 91, 92 - Uncomment and add "postfix"
mode = 0600
user = postfix
group = postfix
Start Dovecot service:
systemctl start dovecot
systemctl enable dovecot
systemctl status dovecot
9.Install Squirrel mail Package
yum install squirrelmail
Configuring Squirrel-Mail
cd /usr/share/squirrelmail/config/
./conf.pl
now the squirrelmail configuration interface will show up in the screen , now change the following options.
Enter 1
Enter 1 and change the organization Name
Press S
Press R for previous menu
Enter 2 for Server settings
Press 1
and type: domainname.local (Name of Domain)
Press 3
Press 2 for switching from Send Mail to SMTP
Type S and Press Q for quit
Create a squirrelmail vhost in apache config file:
nano /etc/httpd/conf/httpd.conf
Enter the following:
Alias /webmail /usr/share/squirrelmail
<Directory /usr/share/squirrelmail>
Options Indexes FollowSymLinks
RewriteEngine On
AllowOverride All
DirectoryIndex index.php
Order allow,deny
Allow from all
</Directory>
10.Restart the http server:
systemctl restart httpd
systemctl enable httpd
systemctl satuts httpd
11.Set SELinux Boolean Set to allow Apache to connect to the network:
setsebool httpd_can_network_connect=1
12.Open Web Browser and type in address bar the following. And Use User Credentials to Login.
http://youipaddress/webmail
Congratulations! You’ve successfully configured a mail server with Postfix, Dovecot, and SquirrelMail on CentOS. You can now send and receive emails using your own mail server. Explore additional configurations and security measures to further enhance your mail server setup.
Contact me
LinkedIn (⌐■_■)
Github (⌐■_■)
Nextpart >>>