RSS
 

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

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

nano /etc/postfix/main.cf

edit the part below to reflect what is below

myhostname = mail.yourdomain.com

mydomain = yourdomain.com

myorigin = $mydomain

inet_interfaces = all
mynetworks_style=host

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

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

recipient_delimiter = +
home_mailbox = Maildir/
mydestination = mail.yourdomain.com, localhost.yourdomain.com, , 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 support@yourdomain.com 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 rackspacecloud.com


yourdomain.com xx.xx.xxx.xxx yourdomain.com 300 A
www.yourdomain.com yourdomain.com yourdomain.com 300 CNAME
yourdomain.com yourdomain.com yourdomain.com 300 MX
mail.yourdomain.com xx.xx.xxx.xxx yourdomain.com 300 A

the last 2 entries is what you should be adding (xx.xx.xxx.xxx = 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 http://yourdomain.com/squirrelmail-webmail-x.x.xx/
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

perl conf.pl

or depending on the location of conf.pl

perl config/conf.pl

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

Sources:
http://www.rackspace.com/knowledge_center/index.php/Postfix_-_MX_Records_and_Receiving_Emails
http://www.linuxmail.info/postfix-smtp-auth-dovecot-sasl/