Install and Configure Cyrus on CentOS

Thursday, August 4th 2016. | how to

#howto ,#tutorial #VPS – Install and Configure Cyrus on CentOS – This tutorial explains step by step guide (with pics) about Install and Configure Cyrus on CentOS

How to setup and configure Cyrus to handle email on CentOS server. A server without ability to send email is somehow still useless. Almost any kind of website scripts, CMS, and even turnkey sites are having email feature allowing visitors, users and anyone to send message to site’s admin. So if you are planning to build a CentOS server to host your websites in, you have to also install Postfix and Cyrus besides the LAMP or LNMP stack itself. I’ve posted about how to setup and configure Postfix earlier, today in this post I will also show you how to get Cyrus up and running on your server.

First, what is Cyrus anyway and why you’ll need it? Cyrus is simply a good companion for Postfix. This software helps your server to organize all emails.

Prerequisite

  1. A working CentOS server. In this guide I am using CentOS 6.3 x32 (see my playground server)
  2. Windows users should download Putty while Mac and Linux users can simply use Terminal
  3. You’ll also need a basic skill to use Putty and to navigate through SSH. Read: Most common Unix commands used to SSH.
  4. Your server should already has necessary software to host a website. In this case are: Apache, PHP5, and MySQL and Postfix.
  5. About 15 minutes of your time and a cup of tea if you like.

How To Install Cyrus

Step 1 – Login to your server and follow my previous guide about Basic setup for CentOS before you build a live web server. You may and may not follow that tutorial but if you followed, it will give you some basic security tweak to your server.

Before you proceed to the next steps, it is better to explain that all commands in this tutorial are written without the “sudo” prefix. However if you disabled root login and you logged in using another username with root privilege, you can add the “sudo” prefix all by your self. Alternatively you can simply type su, hit Enter and type in your password twice to switch login as root.

switch-root-login

You may also need to type this command to go to the root directory:

cd ~

Step 2 – Now issue following command to install Cyrus with sasl component:

yum install cyrus-sasl

install cyrus

As usual, you may also need to confirm by typing Y then hit Enter.

Step 3 – Then also use following command to install Cyrus with imapd component:

yum install cyrus-imapd

Again, confirm it by typing Y.

config cyrus

How to configure Cyrus

Step 1 – Firstly, you have to edit the “smtpd.conf” file, the file that defines the authentication for Postfix/SASL. You can just use vi but in this example I prefer to use Nano editor:

nano /etc/sasl2/smtpd.conf

You’ll see initial lines as below:

setup cyrus

Step 2 – Now replace what you see there with following:

pwcheck_method: auxprop
auxprop_plugin: sasldb
mech_list: PLAIN LOGIN CRAM-MD5 DIGEST-MD5

Once done Save that configuration (hit Control+O) then exit (Control+X).

configure cyrus

Step 3 – Next, you have to also edit the “imapd.conf” file. Again, I use Nano:

nano /etc/imapd.conf

You’ll see some defaults lines as below:

edit cyrus imapd file

Step 4 – Now delete all current lines and use following. p.s: You can copy and paste these text to Notepad then edit domain.com and server name with your actual domain:

virtdomains:		userid
defaultdomain:		domain.com
servername:		mail.domain.com
configdirectory:	/var/lib/imap
partition-default:	/var/spool/imap
admins:			cyrus
sievedir:		/var/lib/imap/sieve
sendmail:		/usr/sbin/sendmail.postfix
hashimapspool:		true
allowanonymouslogin:	no
allowplaintext:		yes
sasl_pwcheck_method:	auxprop
sasl_mech_list:		CRAM-MD5 DIGEST-MD5 PLAIN
tls_cert_file:		/etc/pki/cyrus-imapd/cyrus-imapd.pem
tls_key_file:		/etc/pki/cyrus-imapd/cyrus-imapd.pem
tls_ca_file:		/etc/pki/tls/certs/ca-bundle.crt

autocreatequota:		-1
createonpost:			yes
autocreateinboxfolders:		spam
autosubscribeinboxfolders:	spam

Once done Save that configuration (hit Control+O) then exit (Control+X). In my Playground server it looks like this:

setup cyrus

Step 5 – Well actually that’s it. You are now having Postfix and Cyrus installed. What’s next? You can simply use your contact form in your website (if you built it already) and test it to send email to your personal email (like @gmail.com, @live.com or @yahoo.com). Alternatively you can also install MailX, a free open source email client software for your server so you’ll be able to send email right via command line.

Issue this command syntax:

yum install mailx

Again, confirm it with Y.

install mailx email client

Once done, try to send a test email.

How to use MailX to send email from your CentOS server:

Step 1 – Each time you want to send an email, you have to issue following syntax:

mail recipient@someserver.com

Of course you have to replace recipient@someserver.com with the actual email address you wish to send the mail to. In this example, for testing purpose only, I use free disposable email service from GetAirmail.com.

Step 2 – Once you typed above command syntax and hit Enter, it will ask you to enter the subject of your email. So go ahead type the subject and hit Enter.

Step 3 – Upon hitting Enter, it’s just a blank line where you can then type the whole message there.

Step 4 – Once finished typing all the message, simply hit Enter then type a period (a dot) then hit Enter once again. The period indicates the end of your message and once you hit Enter, mailx sends your email directly. It should look like this:

test email mailx

So here’s the email sent in my inbox:

email sent

And here’s the message

test send email

Done. Do not forget to bookmark this page, share it on Twitter, Facebook and Google+. Do not hesitate to ask me question related to this “how to install Cyrus” guide. You can get quicker update by following me on Twitter.

This post Install and Configure Cyrus on CentOS is part of ServerMom.

Source link