Showing posts with label Mail. Show all posts
Showing posts with label Mail. Show all posts

Sunday, 29 July 2012

SquirrelMail issue and fix (Message Filtering and Multibyte Character display, for CentOS)

I'm happy with SquirrelMail even since I installed it.
(Check my previous post on postfix and dovecot)

Everything is working fine and no big deal really occured.
Until...
01 Start to manage Log-type Messages.
02 Start to compose / receiving multibyte messages...

Issue 01
It was not quite a problem when you think that you can just filter the message,
and move them into a specified folder.
But the problem is "Message Filter" is DISABLED in default.
Search through the web found the solution.
(Only available for the latest version of SquirrelMail?)

If you installed your SquirrelMail through EPEL-repo, you just need to execute:
# /usr/share/squirrelmail/config/conf.pl
Select "Plugin", Select "filter", Save your configuration and quit.
Now you will have "Message Filtering" on the Option Menu.
End of Issue 01.

Issue 02
Well, if you only compose your message using ONLY Alphabets.
Plus, if you do not have any contact that sents you multibyte character included messages.
This might not be an issue for you.

You are unable to view the message properly due to decoding issue. (everything is garbled)
Note that, if you switched your Display Option to that specified language,
you able to view the decoded message properly.
But in my case, I want my SquirrelMail default language as English.
As well I receives Japanese and Chinese messages.

Google's search result lead me to a solution,
where you need to modify the current source. (Japanese site, which says i8n.php is buggy, etc...)
Which i think is not a good idea to do so.
I continue to search for the clue until I fed up and decided to browse through the official site.
Well, what did you know. There is a miracle cure in the download section.
What you need to do is:
- Download "Extra Decoding Library" from the official site's download section.
- Extract the package.
- Copy and Replace the SquirrelMail's function/decode/ directory.

** You will need php-recode for "Extra Decoding Library". Skip this step if you already have it.
# yum install php-recode

Linux command:
01. Download.
# wget http://squirrelmail.org/countdl.php?fileurl=http%3A%2F%2Fprdownloads.sourceforge.net%2Fsquirrelmail%2Fsquirrelmail-decode-1.2.tar.gz

02. Extract and access directory.
# tar xzvf squirrelmail-decode-1.2.tar.gz
# cd squirrelmail-decode-1.2

03. Copy file (execute install, you will be prompted for SquirrelMail's directory: /usr/share/squirrelmail/)
# ./install

04. Check whether files are copied successfully.
# ll /usr/share/squirrelmail/functions/decode/

05. Restart httpd.(Might not needed?)
# service httpd graceful

And there you go.
You can now compose / receive multibyte message with no problem.
... Unless some new encoding method added ...

End of Issue 02.

Thursday, 5 April 2012

How to setup postfix + dovecot mail server based on CentOS 6.2

This have been taking me hours to configure it.

1. Stop the sendmail service and remove it
> service sendmail stop
> yum remove sendmail

2. Install Postfix and Dovecot
> yum install postfix dovecot

3. Edit you hosts file and Add 'mail.yourdomain.com' and 'mail' to 127.0.0.1
> vi /etc/hosts

4. Edit the programs configuration. Mostly about user, servername, etc...
(Will edit later for details)
> vi /etc/postfix/main.cf
> vi /etc/dovecot/dovecot.conf
> vi /etc/aliases

4A. postfix/main.cf sample, configs that added.
myhostname = mail.yourdomain.com
mydomain = yourdomain.com
myorigin = $mydomain
inet_interfaces = all 
inet_protocols = ipv4 # required for CentOS 7 ~ 
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mydestination = $myhostname, $mydomain
mynetworks = 192.168.0.0/24, 127.0.0.0/8
#relay_domains =
home_mailbox = Maildir/
smtpd_recipient_restrictions=permit_mynetworks,reject_unauth_destination
#relayhost = your-hosting-site-mail-relay.yourhostingsite.com
FIGURE 4B. dovecot.conf sample, configs that added.
protocols = imap pop3
mail_location = maildir:~/Maildir
pop3_uidl_format = %08Xu%08Xv 
FIGURE 4C. /etc/aliases sample
# Person who should get root's mail
root:           kiddokenshin

5. Switch your MTA configuration and make sure is SMTP
> alternatives --config mta

6. Add mail user account (without SSH login)
> useradd -s /sbin/nologin youruser
> passwd youruser
> echo "youruserpasswd" | saslpasswd2 -p -u yourdomain.com -c youruser
> sasldblistusers2
> chgrp postfix /etc/sasldb2

7. Start your mail server
> service dovecot start
> service postfix start

8. Check your smtp port availability
> telnet localhost 25

Remember to add MX record and CNAME record on your domain manager. Most probably your mail server is working right now.

!! CAUTION !!
- If you cant send your mail out, most probably its the firewall's fault.
- Some rental server(or hosting site) required you to relay to their mail server to send mail.

If you like to use web browser to view and reply mail,
follow the optional instruction below to install the web based mailer, squirrelmail.

Installing squirrelmail (Optional)
A. Install EPEL Repository
> wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
> rpm -i epel-release-6-5.noarch.rpm

B. Install and Config SquirrelMail
(configure your squirrelmail, such as server name, smtp domain etc...)
> yum install squirrelmail
> /usr/share/squirrelmail/config/conf.pl

C. Edit httpd.conf and Restart httpd (assuming you have httpd)
> vi /etc/httpd/conf/httpd.conf
> service httpd restart

SAMPLE of 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>

Log into http://yourdomain.com/squirrelmail to access it.