Mail-Configure

Mail user: adduser -s /bin/false u1     [u1 only mail user]

User Delete: userdel -r u1

openssl passwd -1 "123456"

useradd -m -p encryptedPass username

useradd -m -p $1$CffaUg.a$C41I9Z61eS9OMrdr.cRSu1 u21 -s /sbin/nologin

Passwd: dhaKa1234

useradd -m -p VCX97jg6iZebc -s /bin/false u1

useradd -m -p VCX97jg6iZebc -s /bin/false u2

useradd -m -p VCX97jg6iZebc -s /bin/false virusalert

useradd -m -p VCX97jg6iZebc -s /bin/false spamalert

useradd -m -p VCX97jg6iZebc -s /bin/false spam.police

useradd -m -p VCX97jg6iZebc -s /bin/false junkmail

useradd -m -p VCX97jg6iZebc -s /bin/false inmail

useradd -m -p VCX97jg6iZebc -s /bin/false outmail

useradd -m -p VCX97jg6iZebc -s /bin/false alluser

useradd -m -p VCX97jg6iZebc -s /bin/false office

[root@ns1 ~]# vi /etc/hosts

127.0.0.1              localhost.localdomain           localhost

::1                         localhost6.localdomain6       localhost6

210.207.201.1      ns1.worldcm.com                   ns1

[root@server ~]# postmap main.cf    [ Any Edit postfix - run this Command ]

                                            virtual

                                            access

#mail -v root@domain.com   [mail check ]

 # system-configure-user

#yum install system-config-display

#system-config-display

#startx

http://www.webmin.com/download.html

wget http://prdownloads.sourceforge.net/webadmin/webmin-1.740-1.noarch.rpm

URL http://localhost:10000

                ----------------------------XXXX------------------------------------

 Upload file size in  webmail: 

# vi /etc/php.ini 

memory_limit = 512M; upload_max_filesize = 30M; post_max_size = 70M;

date.timezone = Asia/Dhaka

LOGO Change

cd  /usr/share/squirrelmail/images

/usr/share/squirrelmail/config/conf.pl

# service httpd restart

Squirrelmail Index configure

#vi /etc/squirrelmail/config.php 

$org_logo_width  = '150';

$org_logo_height = '100';

# service httpd restart

Setup Mail Server using Postfix, Dovecot and SquirrelMail in CentOS/RHEL/Scientific Linux ------------------------------------------------6.3 step by step-----------------------------------------------------------------------

Before install postfix, remove sendmail from the server. Because sendmail is the default MTA in Redhat/CentOS.

[root@server ~]# yum remove sendmail

Prerequisites:

[root@server ~]# service iptables stop

[root@server ~]# service ip6tables stop

[root@server ~]# chkconfig iptables off

[root@server ~]# chkconfig ip6tables off

service iptables stop

service ip6tables stop

chkconfig iptables off

chkconfig ip6tables off

[root@server ~]# vi /etc/selinux/config

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

#     enforcing - SELinux security policy is enforced.

#     permissive - SELinux prints warnings instead of enforcing.

#     disabled - No SELinux policy is loaded.

SELINUX=disabled

# SELINUXTYPE= can take one of these two values:

#     targeted - Targeted processes are protected,

#     mls - Multi Level Security protection.

SELINUXTYPE=targeted

Reboot the server.

Scenario

In this tutorial my test box

Hostname = ns1.worldcm.com

IP Address = 192.168.1.40/24

And my server is configured with proper MX record in DNS server.

RPM install:

yum -y install pcre*

yum -y install pcre-devel

yum -y install postfix-pflogsumm

yum -y install postfix-pflogsumm[root@server ~]# yum install httpd*

[root@server ~]# yum install httpd*

[root@server ~]# yum install postfix*

                        # yum -y install pcre-devel pcre

[root@server ~]# yum install dovecot*

[root@server ~]# yum install mutt*

[root@server ~]# yum install squirrelmail*

Installation

Postfix is installed by default. If it is not installed, use the below command to install postfix.

[root@server ~]# yum install postfix

Configuration Postfix

Open the postfix config file /etc/postfix/main.cf. Find the below lines and edit them as shown below.

[root@server ~]# vi /etc/postfix/main.cf

myhostname = ns1.worldcm.com  ##line no 75 - uncomment and enter your host name

mydomain = worldcm.com  ##line no 83 - uncomment and enter your domain name 

myorigin = $mydomain  ##line no 99 - uncomment

inet_interfaces = all  ##line no 116 - change to all

mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain ##line no 164-Add $mydomain

mynetworks = 192.168.1.0/24, 127.0.0.0/8  ##line no 264 - uncomment and add your network range

home_mailbox = Maildir/       ##line no 419 - uncomment

-----------------------

OR add last line

------------------------

myhostname = ns1.worldcm.com  

mydomain = worldcm.com  

myorigin = $mydomain  

inet_interfaces = all  

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

OR

mydestination = $myhostname, localhost.$mydomain, $mydomain, mail.karnaphuli.com, karnaphuli.com, 203.76.150.59/32

mynetworks = 192.168.1.0/24, 127.0.0.0/8  

home_mailbox = Maildir/   

###############################################

Start the postfix service.

[root@server ~]# service postfix start

Starting postfix:                                             [ OK ]

[root@server ~]# chkconfig postfix on

[root@server ~]# postmap main.cf    [ Any Edit postfix pls run this Command ]

Test Postfix

The commands shown in bold letters should be entered by the user. 

Note: The dot after the test command is important.

[root@server ~]# telnet localhost smtp

Trying ::1...

Connected to localhost.

Escape character is '^]'.

220 server.ostechnix.com ESMTP Postfix

ehlo localhost

250-server.ostechnix.com

250-PIPELINING

250-SIZE 10240000

250-VRFY

250-ETRN

250-ENHANCEDSTATUSCODES

250-8BITMIME

250 DSN

mail from:<user1>

250 2.1.0 Ok

rcpt to:<user1>

250 2.1.5 Ok

data

354 End data with <CR><LF>.<CR><LF>

test

.

250 2.0.0 Ok: queued as 117113FF18

quit

221 2.0.0 Bye

Connection closed by foreign host.

Check Mail

Navigate to the user mail directory and check for the new mail.

[root@server ~]# cd /home/user1/Maildir/new/

[root@server new]# ls

1360236956.Vfd00I35afM181256.server.ostechnix.com

[root@server new]# cat 1360236956.Vfd00I35afM181256.server.worldcm.com 

Return-Path: <user1@worldcm.com>

X-Original-To: user1

Delivered-To: user1@worldcm.com

Received: from localhost (localhost [IPv6:::1])

 by server.ostechnix.com (Postfix) with ESMTP id 117113FF18

 for <user1>; Thu,  7 Feb 2013 17:05:32 +0530 (IST)

Message-Id: <20130207113547.117113FF18@ns1.worldcm.com>

Date: Thu,  7 Feb 2013 17:05:32 +0530 (IST)

From: user1@worldcm.com

To: undisclosed-recipients:;

test

Thats it. Postfix working now.

Install Dovecot : SASL [CentOS 6]

Install Dovecot to configure POP/IMAP server. POP uses 110/TCP, IMAP uses 143/TCP.

Install Dovecot.

[root@mail ~]# yum -y install dovecot 

This example shows to configure to provide SASL function to Postfix.

[root@mail ~]# vi /etc/dovecot/dovecot.conf

protocols = imap pop3 lmtp

#Add line 30

mail_location = maildir:~/Maildir

listen = *                    # line 26: change ( if not use IPv6 )

[root@mail ~]# vi /etc/dovecot/conf.d/10-auth.conf

disable_plaintext_auth = no                                 # line 9: uncomment and change ( allow plain text auth )

auth_mechanisms = plain login                            # line 97: add

[root@mail ~]# vi /etc/dovecot/conf.d/10-mail.conf

mail_location = maildir:~/Maildir             # line 30: uncomment and add

[root@mail ~]# vi /etc/dovecot/conf.d/10-master.conf

#Add line 88-90: uncomment and add

# Postfix smtp-auth

unix_listener /var/spool/postfix/private/auth {

    mode = 0666

    user = postfix

    group = postfix

}

[root@mail ~]# vi /etc/dovecot/conf.d/20-pop3.conf

pop3_uidl_format = %08Xu%08Xv

pop3_client_workarounds = outlook-no-nuls oe-ns-eoh

[root@mail ~]# /etc/rc.d/init.d/dovecot start

Starting Dovecot Imap:

[  OK  ]

[root@mail ~]# chkconfig dovecot on 

-------------------------------------------------

SASL Conf Dovicote

# yum install cyrus-sasl*

# yum -y install cyrus*

----------------------------

Pls check

# vi /usr/lib64/sasl2/smtpd.conf

pwcheck_method: saslauthd

mech_list: PLAIN LOGIN

                                                 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Configure Dovecot : [ NO SASL]

Open the dovecot config file /etc/dovecot/dovecot.conf. Find and uncomment the line as shown below.

[root@server ~]# vi /etc/dovecot/dovecot.conf

protocols = imap pop3 lmtp

mail_location = maildir:~/Maildir  [ Add-line 30]

protocols = pop3 pop3s imap imaps 

pop3_uidl_format = %08Xu%08Xv

Open the file /etc/dovecot/conf.d/10-mail.conf and uncomment the line as shown below.

[root@server ~]# vi /etc/dovecot/conf.d/10-mail.conf

mail_location = maildir:~/Maildir  ##line no 24 - uncomment

Open the /etc/dovecot/conf.d/10-auth.conf and edit as shown below.

[root@server ~]# vi /etc/dovecot/conf.d/10-auth.conf

disable_plaintext_auth = no  ##line no 9 - uncomment and change from yes to no.

auth_mechanisms = plain login  ##line no 97 - add the text "login"

Open the /etc/dovecot/conf.d/10-master.conf and edit as shown below.

[root@server ~]# vi /etc/dovecot/conf.d/10-master.conf

unix_listener auth-userdb {

    #mode = 0600

    user = postfix  ##line no 83 - uncomment and enter postfix

    group = postfix  ##line no 84 - uncomment and enter postfix

Start the dovecot service.

[root@server ~]# service dovecot start

Starting Dovecot Imap:                                [ OK ]

[root@server ~]# chkconfig dovecot on

Test Dovecot

The commands shown in bold should be entered by the user.

[root@server ~]# telnet localhost pop3

Trying ::1...

Connected to localhost.

Escape character is '^]'.

+OK Dovecot ready.

user user1

+OK

pass user1

+OK Logged in.

list

+OK 1 messages:

1 428

.

retr 1

+OK 428 octets

Return-Path: <user1@worldcm.com>

X-Original-To: user1

Delivered-To: user1@worldcm.com

Received: from localhost (localhost [IPv6:::1])

by server.ostechnix.com (Postfix) with ESMTP id 117113FF18

for <user1>; Thu,  7 Feb 2013 17:05:32 +0530 (IST)

Message-Id: <20130207113547.117113FF18@server.worldcm.com>

Date: Thu,  7 Feb 2013 17:05:32 +0530 (IST)

From: user1@worldcm.com

To: undisclosed-recipients:;

test

.

quit

+OK Logging out.

Connection closed by foreign host.

[root@server ~]# 

Dovecot is working now.

OR..................................................-----------------------------------------

yum install mutt*

#mutt u1@ns1.worldcm.com

y-enter

subject then :x

y

su - u1

mutt

y

q

-----------------------------------------------------------------

Install Squirrelmail

Install EPEL repository first. And install SquirrelMail package from EPEL repository.

[root@server ~]# wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

[root@server ~]# rpm -ivh epel-release-6-8.noarch.rpm 

[root@server ~]# yum install squirrelmail

[root@server ~]# service httpd start

Starting httpd:                                            [  OK  ]

[root@server ~]# chkconfig httpd on

[root@server ~]#

 

Configure Squirrelmail

Go to the squirrelmail config directory and use the command ./conf.pl to start configure as shown below.

[root@server ~]# cd /usr/share/squirrelmail/config/

[root@server config]# ./conf.pl

OR

root@www ~]# yum --enablerepo=epel -y install squirrelmail

wget http://www.squirrelmail.org/plugins/html_mail-2.3-1.4.tar.gz -P /usr/share/squirrelmail/plugins

wget http://www.squirrelmail.org/plugins/view_as_html-3.8.tar.gz -P /usr/share/squirrelmail/plugins

wget http://www.squirrelmail.org/plugins/compatibility-2.0.16-1.0.tar.gz -P /usr/share/squirrelmail/plugins

wget http://www.squirrelmail.org/plugins/empty_trash-2.0-1.2.2.tar.gz -P /usr/share/squirrelmail/plugins

wget http://www.squirrelmail.org/plugins/secure_login-1.4-1.2.8.tar.gz -P /usr/share/squirrelmail/plugins

wget http://www.squirrelmail.org/plugins/autocomplete-3.0-1.4.0.tar.gz -P /usr/share/squirrelmail/plugins

tar zxvf /usr/share/squirrelmail/plugins/html_mail-2.3-1.4.tar.gz -C /usr/share/squirrelmail/plugins

tar zxvf /usr/share/squirrelmail/plugins/view_as_html-3.8.tar.gz -C /usr/share/squirrelmail/plugins

tar zxvf /usr/share/squirrelmail/plugins/compatibility-2.0.16-1.0.tar.gz -C /usr/share/squirrelmail/plugins

tar zxvf /usr/share/squirrelmail/plugins/empty_trash-2.0-1.2.2.tar.gz -C /usr/share/squirrelmail/plugins

tar zxvf /usr/share/squirrelmail/plugins/secure_login-1.4-1.2.8.tar.gz -C /usr/share/squirrelmail/plugins

tar zxvf /usr/share/squirrelmail/plugins/autocomplete-3.0-1.4.0.tar.gz -C /usr/share/squirrelmail/plugins

rm -f /usr/share/squirrelmail/plugins/*.tar.gz

[root@www ~]# /usr/share/squirrelmail/config/conf.pl

SquirrelMail Configuration : Read: config.php (1.4.0) ---------------------------------------------------------

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 

Select option 1 and set organization details.

SquirrelMail Configuration : Read: config.php (1.4.0)

---------------------------------------------------------

Organization Preferences

1.  Organization Name      : WORLDCM

2.  Organization Logo      : ../images/sm_logo.png

3.  Org. Logo Width/Height : (308/111)

4.  Organization Title     : Welcome to WORLDCM webmail

5.  Signout Page           : 

6.  Top Frame              : _top

7.  Provider link          : http://worldcm.com

8.  Provider name          : worldcm

R   Return to Main Menu

C   Turn color off

S   Save data

Q   Quit

Command >>R 

Press R to return main menu and select option 2. Enter your domain name and select dovecot in the Sendmail or SMTP parameter.

SquirrelMail Configuration : Read: config.php (1.4.0)

---------------------------------------------------------

Server Settings

General

-------

1.  Domain                 : ostechnix.com

2.  Invert Time            : false

3.  Sendmail or SMTP       : SMTP

A.  Update IMAP Settings   : localhost:143 (uw)

B.  Update SMTP Settings   : localhost:25

R   Return to Main Menu

C   Turn color off

S   Save data

Q   Quit

Command >> S

Once you done, press S to save datas and press Q to exit.

SSL

[root@www ~]# vi /usr/share/squirrelmail/plugins/secure_login/config.php

# line 24: change (continue to connect with SSL after login)

$change_back_to_http_after_login = 0

;

[root@www ~]# /etc/rc.d/init.d/httpd reload

Reloading httpd:     [  OK  ]

LOGO change

#  cd /usr/share/squirrelmail/images

 HTP Configure

Add the following lines in the httpd.conf file at the end.

In last line add this line

 

[root@server ~]# vi /etc/httpd/conf/httpd.conf

Alias /squirrelmail /usr/share/squirrelmail

<Directory /usr/share/squirrelmail>

    Options Indexes FollowSymLinks

    RewriteEngine On

    AllowOverride All

    DirectoryIndex index.php

    Order allow,deny

    Allow from all

</Directory>

OR  root

Line: 402

DirectoryIndex index.html index.html

Line: 292

DocumentRoot "/usr/share/squirrelmail"

Line: 990

NameVirtualHost localhost.localdomain:80

Line:add this end

<VirtualHost *:80>

DocumentRoot /usr/share/squirrelmail

ServerName mail.worldcm.net

</VirtualHost>

---------------------------------------------------------

[root@ns1 ~]# setsebool httpd_can_network_connect=1

[root@ns1 ~]# getsebool httpd_can_network_connect

--------------------------------------------------------------

 

 

Restart the httpd service. 

[root@server ~]# service httpd restart

Stopping httpd:                                            [  OK  ]

Starting httpd:                                            [  OK  ]

[root@server ~]# 

Create Users

[root@server ~]# useradd user1

[root@server ~]# useradd user2

[root@server ~]# passwd user1

[root@server ~]# passwd user2

Open the browser from any clients. Type the following in the address bar.

http://worldcm/webmail

or

http://yourdomainname/webmail


---------------------------------------------------

password change

Install the SquirrelMail Change Password Plugin

Service Configuration1. Install the Poppassd service.

                          -                                 -----------------------------------

Change Passwd Squirrelmail

cd /usr/share/squirrelmail/plugins/compatibility/

patch -p0 < patches/compatibility_patch-1.4.8.diff 

 Replace 1.4.8 with your SquirrelMail version. GEdit9. In the /usr/share/squirrelmail/plugins/change_passwd directory, copy the file config.php.sample and save it as config.php. Edit config.php and review the default settings. Below are settings in config.php you may wish to change * $minimumPasswordLength– Minimum length of the password. * $changePasswdInLogin – Change password from the login form. Test the SquirrelMail Change Password SquirrelMail1. Login to SquirrelMail and go to the Options page. You should see the new Change Password section. SquirrelMail2. Click the Change Password link to view the new Change Password page. 

poppassd-1.8.5-lux.4.x86_64.rpm                                              

4. Edit the file /etc/pam.d/poppassd and replace the content with the lines below.

auth         required     pam_unix.so

account      required     pam_unix.so

password     requisite    pam_cracklib.so

password     sufficient   pam_unix.so md5 shadow

#############################################################################################################

How to setup mail server in centos 6 (postfix-dovecot )

---------------------------------------------------------------------------------------------------------------------------------------------------------------

configure .

» Postfix ( for sending )

» Dovecot ( for receiving )

» Squirrelmail ( for webmail access )

Setup mail server in centos 6

» Installing and configuring  postfix

Step 1 »Before installation assign a static ip and add a host entry for your domain to that IP in the /etc/hosts file like below.

192.168.0.15 krizna.com

Step 2 » Issue the below command to install postfix

[root@mail ~]# yum -y install postfix

Step 3 » Now issue the below command to install SMTP AUTH packages .

[root@mail ~]# yum -y install cyrus-sasl cyrus-sasl-devel cyrus-sasl-gssapi cyrus-sasl-md5 cyrus-sasl-plain

Postfix package installation is completed .

Step 4 » Issue the below commands one by one for creating SSL Cert.

[root@mail ~]# mkdir /etc/postfix/ssl

[root@mail ~]# cd /etc/postfix/ssl/

[root@mail ssl]# openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024

[root@mail ssl]# chmod 600 smtpd.key

[root@mail ssl]# openssl req -new -key smtpd.key -out smtpd.csr

[root@mail ssl]# openssl x509 -req -days 365 -in smtpd.csr -signkey smtpd.key -out smtpd.crt

[root@mail ssl]# openssl rsa -in smtpd.key -out smtpd.key.unencrypted

[root@mail ssl]# mv -f smtpd.key.unencrypted smtpd.key

[root@mail ssl]# openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 365

Step 4 » Now open /etc/postfix/main.cf file .

Find and comment the below lines .

#inet_interfaces = localhost #---> line no 116

#mydestination = $myhostname, localhost.$mydomain, localhost #--> line no 164

and add these lines at the bottom of the file.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

myhostname = mail.krizna.com

mydomain = krizna.com

myorigin = $mydomain

home_mailbox = mail/

mynetworks = 127.0.0.0/8

inet_interfaces = all

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

smtpd_sasl_auth_enable = yes

smtpd_sasl_type = cyrus

smtpd_sasl_security_options = noanonymous

broken_sasl_auth_clients = yes

smtpd_sasl_authenticated_header = yes

smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination

smtpd_tls_auth_only = no

smtp_use_tls = yes

smtpd_use_tls = yes

smtp_tls_note_starttls_offer = yes

smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key

smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt

smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem

smtpd_tls_received_header = yes

smtpd_tls_session_cache_timeout = 3600s

tls_random_source = dev:/dev/urandom

Step 5 » Now open /etc/postfix/master.cf file and add the below line after smtp

1

2

3

4

5

smtps     inet  n       -       n       -       -       smtpd

      -o smtpd_sasl_auth_enable=yes

      -o smtpd_reject_unlisted_sender=yes

      -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject

      -o broken_sasl_auth_clients=yes

Step 6 » Now start postfix and saslauthd service

[root@mail ~]# service postfix start

[root@mail ~]# service saslauthd start

» Issue the below commands to start the postfix and saslauthd at startup

[root@mail ~]# chkconfig --level 235 postfix on

[root@mail ~]# chkconfig --level 235 saslauthd on

Step 7 » Now check your smtp connectivity . just telnet localhost on port 25 and type this command ehlo localhost

[root@mail ~]# telnet localhost 25

Trying ::1...

Connected to localhost.

Escape character is '^]'.

220 mail.krizna.com ESMTP Postfix

ehlo localhost <---- type this command 

250-mail.krizna.com

250-PIPELINING

250-SIZE 10240000

250-VRFY

250-ETRN

250-STARTTLS

250-AUTH PLAIN LOGIN

250-AUTH=PLAIN LOGIN

250-ENHANCEDSTATUSCODES

250-8BITMIME

250 DSN

quit

221 2.0.0 Bye

Connection closed by foreign host.

If you get this output .. Great .. everything is fine till now.