{"id":4414,"date":"2013-03-05T23:12:15","date_gmt":"2013-03-05T15:12:15","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=4414"},"modified":"2023-04-28T09:48:56","modified_gmt":"2023-04-28T09:48:56","slug":"how-to-setup-mailwatch-on-centos-6-3","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-setup-mailwatch-on-centos-6-3\/","title":{"rendered":"How to Setup MailWatch on CentOS 6.3"},"content":{"rendered":"<p>MailWatch for MailScanner is a open source or free web-based front-end to Mailscanner that use to displays the inbound\/outbound mail queue, spam, viruses and blocked content on each page header. MailWatch has been written in PHP, MySQL and JpGraph. By using Mailwatch, it allows you to delete, release or run sa-learn across any messages that was quarantined. This post describes how to setup MailWatch on CentOS 6.3 and assumed that you already installed MailScanner and postfix.<\/p>\n<p>1. Install required php and mysql :<\/p>\n<pre>[root@mx1 ~]# yum install php mysql-server mysql php-gd php-mysql -y<\/pre>\n<p>2. Modify the php.ini :<\/p>\n<pre>[root@mx1 ~]# vim \/etc\/php.ini<\/pre>\n<p>PHP should have the following set in php.ini<\/p>\n<pre> short_open_tag = On\n safe_mode = Off\n register_globals = Off\n magic_quotes_gpc = On\n magic_quotes_runtime = Off\n session.auto_start = 0<\/pre>\n<p>3. Download the latest version from mailwatch.sourceforge.net :<\/p>\n<pre>[root@mx1 ~]# wget http:\/\/sourceforge.net\/projects\/mailwatch\/files\/mailwatch\/1.1.5.1\/mailwatch-1.1.5.1.tar.gz<\/pre>\n<p>4. Extract downloaded mailwatch package :<\/p>\n<pre>[root@mx1 ~]# tar xzvf mailwatch-1.1.5.1.tar.gz<\/pre>\n<p>5. Start mysql service :<\/p>\n<pre>[root@mx1 ~]# service mysqld start\nInitializing MySQL database:  WARNING: The host 'mx1.ehowstuff.local' could not be looked up with resolveip.\nThis probably means that your libc libraries are not 100 % compatible\nwith this binary MySQL version. The MySQL daemon, mysqld, should work\nnormally with the exception that host name resolving will not work.\nThis means that you should use IP addresses instead of hostnames\nwhen specifying MySQL privileges !\nInstalling MySQL system tables...\nOK\nFilling help tables...\nOK\n\nTo start mysqld at boot time you have to copy\nsupport-files\/mysql.server to the right place for your system\n\nPLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !\nTo do so, start the server, then issue the following commands:\n\n\/usr\/bin\/mysqladmin -u root password 'new-password'\n\/usr\/bin\/mysqladmin -u root -h mx1.ehowstuff.local password 'new-password'\n\nAlternatively you can run:\n\/usr\/bin\/mysql_secure_installation\n\nwhich will also give you the option of removing the test\ndatabases and anonymous user created by default.  This is\nstrongly recommended for production servers.\n\nSee the manual for more instructions.\n\nYou can start the MySQL daemon with:\ncd \/usr ; \/usr\/bin\/mysqld_safe &amp;\n\nYou can test the MySQL daemon with mysql-test-run.pl\ncd \/usr\/mysql-test ; perl mysql-test-run.pl\n\nPlease report any problems with the \/usr\/bin\/mysqlbug script!\n\n                                                           [  OK  ]\nStarting mysqld:                                           [  OK  ]<\/pre>\n<p>6. Enter extracted mailwatch-x.x directory :<\/p>\n<pre>[root@mx1 mailwatch-1.1.5.1]# ls\nCHANGELOG   fix_quarantine_permissions  LICENSE  mailscanner               Remote_DB.txt  upgrade.php  USER_FILTERS\ncreate.sql  INSTALL                     luser    MailScanner_perl_scripts  tools          UPGRADING\n[root@mx1 mailwatch-1.1.5.1]# mysql -p &lt; create.sql<\/pre>\n<p>7. Create the database and import create.sql. The following commands below should be run as the &#8216;root&#8217; :<\/p>\n<pre>[root@mx1 mailwatch-1.1.5.1]# mysql -p &lt; create.sql\nEnter password:<\/pre>\n<p>8. Login to mysql as a root :<\/p>\n<pre>[root@mx1 mailwatch-1.1.5.1]# mysql -u root -p\nEnter password:\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 3\nServer version: 5.1.67 Source distribution\n\nCopyright (c) 2000, 2012, Oracle and\/or its affiliates. All rights reserved.\n\nOracle is a registered trademark of Oracle Corporation and\/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql&gt;<\/pre>\n<p>9. Proceed to create a MySQL user and then set password and configure MailScanner for SQL logging :<\/p>\n<pre>mysql&gt; GRANT ALL ON mailscanner.* TO mailwatch@localhost IDENTIFIED BY 'password';\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql&gt; GRANT FILE ON *.* TO mailwatch@localhost IDENTIFIED BY 'password';\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql&gt; FLUSH PRIVILEGES;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql&gt; show databases;\n+--------------------+\n| Database           |\n+--------------------+\n| information_schema |\n| mailscanner        |\n| mysql              |\n| test               |\n+--------------------+\n4 rows in set (0.00 sec)<\/pre>\n<p>10. Edit MailWatch.pm and change the database values accordingly :<\/p>\n<p>a. Enter to the perl_scripts&#8217;s folder :<\/p>\n<pre>[root@mx1 mailwatch-1.1.5.1]# cd MailScanner_perl_scripts\n[root@mx1 MailScanner_perl_scripts]# pwd\n\/root\/mailwatch-1.1.5.1\/MailScanner_perl_scripts<\/pre>\n<p>b. Edit MailWatch.pm :<\/p>\n<pre>[root@mx1 MailScanner_perl_scripts]# vim MailWatch.pm<\/pre>\n<p>c.Modify this as necessary for your configuration<\/p>\n<pre>my($db_name) = 'mailscanner';\nmy($db_host) = 'localhost';\nmy($db_user) = 'mailwatch';\nmy($db_pass) = 'password';<\/pre>\n<p>11. Move MailWatch.pm to \/usr\/lib\/MailScanner\/MailScanner\/CustomFunctions :<\/p>\n<pre>[root@mx1 MailScanner_perl_scripts]# cp MailWatch.pm \/usr\/lib\/MailScanner\/MailScanner\/CustomFunctions<\/pre>\n<p>12. Create a MailWatch web user. This user will able to monitor the mailscanner through MailWatch web interface.<\/p>\n<pre>[root@mx1 ~]# mysql mailscanner -u mailwatch -p\nEnter password:\nReading table information for completion of table and column names\nYou can turn off this feature to get a quicker startup with -A\n\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 8\nServer version: 5.1.67 Source distribution\n\nCopyright (c) 2000, 2012, Oracle and\/or its affiliates. All rights reserved.\n\nOracle is a registered trademark of Oracle Corporation and\/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql&gt; INSERT INTO users SET username = 'admin', password = md5('password'), fullname = 'MAilwatch Administrator', type ='A';\nQuery OK, 1 row affected (0.00 sec)<\/pre>\n<p>13. Install &amp; Configure MailWatch :<br \/>\na. Enter to mailwatch directory :<\/p>\n<pre>[root@mx1 ~]# cd mailwatch-1.1.5.1<\/pre>\n<p>b. Move mailscanner folder for web root folder. For apache, default root folder is \/var\/www\/html :<\/p>\n<pre>[root@mx1 mailwatch-1.1.5.1]# mv mailscanner \/var\/www\/html\/<\/pre>\n<p>c. Enter to mailscanner folder in web root directory :<\/p>\n<pre>[root@mx1 ~]# cd \/var\/www\/html\/mailscanner<\/pre>\n<p>d. Verify and check the permissions of \/var\/www\/html\/mailscanner\/images and \/var\/www\/html\/images\/cache. The permissions and ownerships should be as below :<\/p>\n<pre>[root@mx1 mailscanner]# chown root:apache images\n[root@mx1 mailscanner]# chmod ug+rwx images\n[root@mx1 mailscanner]# chown root:apache images\/cache\n[root@mx1 mailscanner]# chmod ug+rwx images\/cache<\/pre>\n<p>14. Create conf.php by copying conf.php.example. Edit the values to any details as you created earlier :<\/p>\n<p>a. Copy the conf.php :<\/p>\n<pre>[root@mx1 mailscanner]# cp conf.php.example conf.php<\/pre>\n<p>b. Open conf.php :<\/p>\n<pre>[root@mx1 mailscanner]# vim conf.php<\/pre>\n<p>c. Edit the details as below :<\/p>\n<pre>define('DB_TYPE', 'mysql');\ndefine('DB_USER', 'mailwatch');\ndefine('DB_PASS', 'password');\ndefine('DB_HOST', 'localhost');\ndefine('DB_NAME', 'mailscanner');<\/pre>\n<p>15. Before setup the mailscanner, make sure it&#8217;s Stopped. Run 3 to 4 times to ensure the mailscanner completely stop. The status will FAILED if mailscanner completely stop.<\/p>\n<pre>[root@mx1 ~]# service MailScanner stop\nShutting down MailScanner daemons:\n         MailScanner:                                      [  OK  ]\n         incoming postfix:                                 [  OK  ]\n         outgoing postfix:                                 [  OK  ]\n[root@mx1 ~]# service MailScanner stop\nShutting down MailScanner daemons:\n         MailScanner:                                      [  OK  ]\n         incoming postfix:                                 [  OK  ]\n         outgoing postfix:                                 [  OK  ]\n[root@mx1 ~]# service MailScanner stop\nShutting down MailScanner daemons:\n         MailScanner:                                      [  OK  ]\n         incoming postfix:                                 [  OK  ]\n         outgoing postfix:                                 [  OK  ]\n[root@mx1 ~]# service MailScanner stop\nShutting down MailScanner daemons:\n         MailScanner:                                      [  OK  ]\n         incoming postfix:                                 [  OK  ]\n         outgoing postfix:                                 [  OK  ]\n[root@mx1 ~]# service MailScanner stop\nShutting down MailScanner daemons:\n         MailScanner:                                      [FAILED]\n         incoming postfix:                                 [  OK  ]\n         outgoing postfix:                                 [  OK  ]<\/pre>\n<p>16. Edit \/etc\/MailScanner\/MailScanner.conf.<\/p>\n<pre>[root@mx1 ~]# vim \/etc\/MailScanner\/MailScanner.conf<\/pre>\n<p>Make sure that the following options are set:<\/p>\n<pre> Always Looked Up Last = &amp;MailWatchLogging\n Detailed Spam Report = yes\n Quarantine Whole Message = yes\n Quarantine Whole Message As Queue Files = no\n Include Scores In SpamAssassin Report = yes\n Quarantine User = root\n Quarantine Group = apache (this should be the same group as your web server)\n Quarantine Permissions = 0660<\/pre>\n<p>17. Start MailScanner :<\/p>\n<pre>[root@mx1 ~]# service MailScanner start\nStarting MailScanner daemons:\n         incoming postfix:                                 [  OK  ]\n         outgoing postfix:                                 [  OK  ]\n         MailScanner:                                      [  OK  ]<\/pre>\n<p>18. Restart httpd service :<\/p>\n<pre>[root@mx1 ~]# service httpd restart<\/pre>\n<p>19. Make sure all the related service such as httpd, mysql and MailScanner configured to start at boot :<\/p>\n<pre>[root@mx1 ~]# chkconfig mysqld on\n[root@mx1 ~]# chkconfig httpd on\n[root@mx1 ~]# chkconfig MailScanner on\n[root@mx1 ~]# chkconfig spamassassin on\n[root@mx1 ~]# chkconfig postfix on<\/pre>\n<p>20. Check the mail log.<\/p>\n<pre>[root@mx1 ~]# tail -f \/var\/log\/maillog<\/pre>\n<p>You should see something as below :<\/p>\n<pre>Mar  5 22:14:42 mx1 MailScanner[1718]: Using locktype = flock\nMar  5 22:14:43 mx1 MailScanner[1697]: Requeue: C297BA1C3F.AA850 to E7373A1DD6\nMar  5 22:14:43 mx1 postfix\/qmgr[1687]: E7373A1DD6: from=&lt;root@mx1.ehowstuff.local&gt;, size=609, nrcpt=1 (queue active)\nMar  5 22:14:43 mx1 MailScanner[1697]: Uninfected: Delivered 1 messages\nMar  5 22:14:43 mx1 MailScanner[1697]: Deleted 1 messages from processing-database\nMar  5 22:14:43 mx1 MailScanner[1697]: Logging message C297BA1C3F.AA850 to SQL\nMar  5 22:14:43 mx1 postfix\/local[1768]: E7373A1DD6: to=&lt;root@mx1.ehowstuff.local&gt;, orig_to=, relay=local, delay=166894, delays=166894\/0.13\/0\/0.02, dsn=2.0.0, status=sent (delivered to mailbox)\nMar  5 22:14:43 mx1 postfix\/qmgr[1687]: E7373A1DD6: removed\nMar  5 22:56:25 mx1 postfix\/postfix-script[1869]: fatal: the Postfix mail system is already running\nMar  5 23:01:08 mx1 update.bad.phishing.sites: Delaying cron job up to 600 seconds<\/pre>\n<p>21. Login to mailwatch web interface :<br \/>\n<img decoding=\"async\" class=\"alignnone size-full wp-image-4417 lazyload\" alt=\"1\" data-src=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2013\/03\/1.png\" width=\"528\" height=\"296\" data-srcset=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2013\/03\/1.png 528w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2013\/03\/1-300x168.png 300w\" data-sizes=\"(max-width: 528px) 100vw, 528px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 528px; --smush-placeholder-aspect-ratio: 528\/296;\" \/><\/p>\n<p><img decoding=\"async\" class=\"alignnone  wp-image-4418 lazyload\" alt=\"2\" data-src=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2013\/03\/2.png\" width=\"674\" height=\"215\" data-srcset=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2013\/03\/2.png 1249w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2013\/03\/2-300x96.png 300w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2013\/03\/2-768x245.png 768w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2013\/03\/2-1024x327.png 1024w\" data-sizes=\"(max-width: 674px) 100vw, 674px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 674px; --smush-placeholder-aspect-ratio: 674\/215;\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>MailWatch for MailScanner is a open source or free web-based front-end to Mailscanner that use to displays the inbound\/outbound mail queue, spam, viruses and blocked content on each page header&#8230;.<\/p>\n","protected":false},"author":6,"featured_media":4419,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[2065],"tags":[1244,1254,1559,1560,1946,1951,1953],"class_list":["post-4414","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mail","tag-centos","tag-centos-6-3","tag-mailscanner","tag-mailwatch","tag-zimbra","tag-zimbra-collaboration-suite","tag-zimbra-mail-server"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/4414","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=4414"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/4414\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/4419"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=4414"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=4414"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=4414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}