Wednesday 5 April 2017

Postfix Mail Server Setup with Dovecot and Squirrelmail Configuration::

Postfix Mail Server Setup with  Dovecot and Squirrelmail Configuration::
============================================================

The below configuration steps are for configuring mail server and client locally in an office atmosphere, so that users in the  office can send and receive mails under the same domain locally.

If you want to sent mails to public domains, you need to register your domain and should have a dedicated Ipaddress for this server and MX record  pointed to the server in the ISP.

Postfix is a secure MTA mainly suitable for medium sized users. For example, can be used in  a medium sized organization. It can be configured along with Dovecot and Squirrelmail as in  exim and qmail.

If your requirement have thousand of email users, and different domains as in a shared hosting scenario, preferably exim is a better choice.


I have disabled firewall for the time being for test configuration.

Postfix Installation::

# yum install postfix

After installation edit /etc/postfix/main.cf
# vi /etc/postfix/main.cf
Add the below entries based on your hostname and domain

myhostname = linuxgeeknotes.com
mydomain = linuxgeeknotes.com
myorigin = $mydomain
inet_interfaces = all
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mynetworks = 192.168.240.0/24, 127.0.0.0/8
home_mailbox = Maildir/

# systemctl start postfix

Now create test users  for eg:- test1, test2, test3 etc with passwords,  using useradd command.


Dovecot Installation::

# yum install dovecot

After installation edit the configuration files [[  dovecot.conf,  10-mail.conf,   10-auth.conf,  10-master.conf  ]] as follows::

# vi /etc/dovecot/dovecot.conf
protocols = imap pop3 lmtp

# vi /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:~/Maildir

# vi /etc/dovecot/conf.d/10-auth.conf
disable_plaintext_auth = yes
auth_mechanisms = plain login

# vi /etc/dovecot/conf.d/10-master.conf
Make changes as shown below:
#mode = 0600
   user = postfix
   group = postfix
[...]

# systemctl start dovecot

Squirrelmail installation::

# yum install squirrelmail

After installation change to /usr/share/squirrelmail/config/ directory:

# cd /usr/share/squirrelmail/config/

..and run
# ./conf.pl

Now read carefully and complete the squirrelmail configuration steps:-

SquirrelMail Configuration : Read: config.php
---------------------------------------------------------
Main Menu --
1. Organization Preferences
2. Server Settings
3. Folder Defaults
4. General Options
5. Themes
6. Address Books
7. Message of the Day (MOTD)
8. Plugins
9. Database
10. Languages

D. Set pre-defined settings for specific IMAP servers

C Turn color off
S Save data
Q Quit

Command >> 1

The following wizard will open. Enter “1” again to modify your organization details:

SquirrelMail Configuration : Read: config.php
---------------------------------------------------------
Organization Preferences
1. Organization Name : SquirrelMail
2. Organization Logo : ../images/sm_logo.png
3. Org. Logo Width/Height : (308/111)
4. Organization Title : SquirrelMail $version
5. Signout Page :
6. Top Frame : _top
7. Provider link : http://squirrelmail.org/
8. Provider name : SquirrelMail

R Return to Main Menu
C Turn color off
S Save data
Q Quit

Command >> 1

Set your Organization name and press Enter:

We have tried to make the name SquirrelMail as transparent as
possible. If you set up an organization name, most places where
SquirrelMail would take credit will be credited to your organization.

If your Organization Name includes a '$', please precede it with a \.
Other '$' will be considered the beginning of a variable that
must be defined before the $org_name is printed.
$version, for example, is included by default, and will print the
string representing the current SquirrelMail version.

[SquirrelMail]: linuxgeeknotes.com

Similarly, set all the details such as organization title, logo, provider name in the above wizard. Once you done, press “S” to save the changes, and press “R” to return back to your main menu:

SquirrelMail Configuration : Read: config.php
---------------------------------------------------------
Organization Preferences
1.  Organization Name      : linuxgeeknotes
2.  Organization Logo      : ../images/sm_logo.png
3.  Org. Logo Width/Height : (308/111)
4.  Organization Title     : SquirrelMail $version
5.  Signout Page             :
6.  Top Frame                : _top
7.  Provider link             : http://squirrelmail.org/
8.  Provider name          : Linuxgeeknotes Mail

R   Return to Main Menu
C   Turn color off
S   Save data
Q   Quit

Command >> S

Now, enter “2” to setup mail Server settings such as domain name and mail agent etc.:

SquirrelMail Configuration : Read: config.php
---------------------------------------------------------
Main Menu --
1.  Organization Preferences
2.  Server Settings
3.  Folder Defaults
4.  General Options
5.  Themes
6.  Address Books
7.  Message of the Day (MOTD)
8.  Plugins
9.  Database
10. Languages

D.  Set pre-defined settings for specific IMAP servers

C   Turn color off
S   Save data
Q   Quit

Command >> 2

Enter “1”, Enter your mail domain (ex. linuxgeeknotes) and press Enter key.

SquirrelMail Configuration : Read: config.php
---------------------------------------------------------
Server Settings

General
-------
1. Domain : localhost
2. Invert Time : false
3. Sendmail or SMTP : Sendmail

A. Update IMAP Settings : localhost:143 (uw)
B. Change Sendmail Config : /usr/sbin/sendmail

R Return to Main Menu
C Turn color off
S Save data
Q Quit

Command >> 1

[localhost]: linuxgeeknotes.com

Enter “3” and change from sendmail to Postfix MTA (i.e. SMTP):

SquirrelMail Configuration : Read: config.php
---------------------------------------------------------
Server Settings

General
-------
1.  Domain                  : linuxgeeknotes.com
2.  Invert Time            : false
3.  Sendmail or SMTP       : Sendmail

A.  Update IMAP Settings   : localhost:143 (uw)
B.  Change Sendmail Config : /usr/sbin/sendmail

R   Return to Main Menu
C   Turn color off
S   Save data
Q   Quit

Command >> 3

Enter “2” to switch from sendmail MTA to postfix.

You now need to choose the method that you will use for sending
messages in SquirrelMail.  You can either connect to an SMTP server
or use sendmail directly.

  1.  Sendmail
  2.  SMTP
Your choice [1/2] [1]: 2

Now enter “S” followed by “Q” to save and exit Squirrelmail configuration.

Create a squirrelmail vhost in apache config file:

vi /etc/httpd/conf/httpd.conf

Add the following lines at the end:

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>

Restart the Apache service:

# systemctl restart httpd

Access Webmail

Now browse http://ip-address/webmail or http://domain-name/webmail from your browser. You should be able to login to the webmail with the users created before and send mails.