Archive for July, 2011

How to install and configure sending and recieving emails on Centos 5.5

30 Jul

ok. I had a hard time installing mail on my fresh server. There are definitely many tutorials out there but they just seem to be designed for advanced users.
after battling for hours, I finally got sendmail uninstalled, my DNS MX and A records updated, postfix installed, dovecot installed, squirrelmail installed and all talking to one another without problems.

i stand to be corrected in case i say what’s not. am still new with linux.

yum install postfix dovecot system-switch-mail system-switch-mail-gnome

note that i skipped some settings, those settings skipped should be left the way it is

nano /etc/postfix/

edit the part below to reflect what is below

myhostname =

mydomain =

myorigin = $mydomain

inet_interfaces = all

mynetworks = [::ffff:]/104 [::1]/128

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases

recipient_delimiter = +
home_mailbox = Maildir/
mydestination =,, , localhost

save that and exit nano

next lets configure dovecot

nano /etc/dovecot/dovecot.conf

edit it to reflect this, if lines are not there check the include fildes. some settings are in it
protocols = pop3 imap
mail_location = maildir:~/Maildir/
pop3_uidl_format = %08Xu%08Xv
imap_client_workarounds = delay-newmail outlook-idle netscape-eoh
pop3_client_workarounds = outlook-no-nuls oe-ns-eoh

now lets set the aliases, that way, when someone sends email to say the root can get it if you want
something like this.

payments: root
accounts: root
billing: root

now who will receive the mails from root has to be set to a user.
in my case i had something like this

root: admin

so after saving and exiting, i had to create a user called admin and give him a password

useradd admin
passwd admin

in case you have another user you want to recieve emails, just ignore my last step

next we need to make dovecot startup as a service

chkconfig --level 345 dovecot on

start the services

service dovecot start
service postfix start

next you have to go over to your DNS host. i mean the host you pointed you domain name to
if you purchase from godaddy and pointed ur NS to rackspace, then you should be going to rackspace to edit your mx records.
my host has a clean interface to do this

i copied this straight from my account with 300 A 300 CNAME 300 MX 300 A

the last 2 entries is what you should be adding ( = ip of server) may take time to propagate thru DNSes
next you need to configure our firewall to kindly open port 25 for mails to come in, then save and restart the firewall

iptables -I INPUT -p tcp --dport 25 -j ACCEPT
service iptables save
service iptables restart

by now you should be able to send and receive emails but reading the emails can be very challenging, so we need squirrelmail.

remove yum so she doesn’t interfere

yum remove sendmail

next, download squirrelmail, i dont know how you have to do this just google and get it on server

extract it
tar -zxvf squirrelmail-webmail-x.x.xx.tar.gz

next move it to a dirrectory accessible on server via http
so that when you type
you can access it

you will need perl to install squirrelmail
if you dont have it, just

yum install perl
next cd into the squirrelmail dir

run this command


or depending on the location of

perl config/

follow the steps to the end

also note that you will end up creating a directory manually and give the ownership to root:apache

mkdir /var/squirrelmail
mkdir /var/squirrelmail/data
mkdir /var/squirrelmail/attach

chown root:apache /var/squirrelmail
chmod 730 /var/squirrelmail

chown root:apache /var/squirrelmail/data
chmod 730 /var/squirrelmail/data

chown root:apache /var/squirrelmail/attach
chmod 730 /var/squirrelmail/attach

the rest should be a breeze