April 17, 2012

 Updating Dovecot

Newer versions of Dovecot contain updates to the handling of uidlist files - the issues of which, may lead to difficulties when receiving emails via POP3 or IMAP. It may be a good idea to update your installation.

Atmail 6.3.6 uses the 1.2 branch; newer versions of this branch are available for download via: http://www.dovecot.org/download.html

To update, just do the following:

1.) Download the latest sources from the above link:

% wget "http://www.dovecot.org/releases/1.2/dovecot-1.2.17.tar.gz"

2.) Untar, then go into the untarred directory:

%  tar xvfz dovecot-1.2.17.tar.gz
% cd dovecot-1.2.17

3.) Stop the Atmail service:

% /etc/init.d/atmailserver stop

4.) Configure, install:

% ./configure --prefix=/usr/local/atmail/mailserver/ --with-mysql --with-ldap --with-docs=no
% make && make install

5.) Start the Atmail service:

% /etc/init.d/atmailserver restart

Congratulations! Now you have the latest Dovecot binaries installed.


Filed under: Uncategorized — John Contad @ 11:30 pm

 

 Updating Dovecot

Newer versions of Dovecot contain updates to the handling of uidlist files - the issues of which, may lead to difficulties when receiving emails via POP3 or IMAP. It may be a good idea to update your installation.

Atmail 6.3.6 uses the 1.2 branch; newer versions of this branch are available for download via: http://www.dovecot.org/download.html

To update, just do the following:

1.) Download the latest sources from the above link:

% wget "http://www.dovecot.org/releases/1.2/dovecot-1.2.17.tar.gz"

2.) Untar, then go into the untarred directory:

%  tar xvfz dovecot-1.2.17.tar.gz
% cd dovecot-1.2.17

3.) Stop the Atmail service:

% /etc/init.d/atmailserver stop
4.) Configure, install:

% ./configure --prefix=/usr/local/atmail/mailserver/ --with-mysql --with-ldap --with-docs=no
% make && make install

5.) Start the Atmail service:

% /etc/init.d/atmailserver restart

Congratulations! Now you have the latest Dovecot binaries installed.


Filed under: Uncategorized — John Contad @ 10:18 pm

 

December 6, 2011

 Kernel Errors on Terminal when using CentOS

Some Atmail appliances and machines may find the following similar output to their terminal, at 1-second intervals:

 atmail kernel: EDAC MC0: UE page 0x0, offset 0x0, grain 1073741824, row 5, labels ":": i3200 UET

This is caused by a kernel issue affecting CentOS and Fedora machines. You will need to disable that particular module. Open up /etc/modprobe.d/blacklist.conf, and add:

blacklist i3200_edac
Restart your machine afterward.


Filed under: Uncategorized — John Contad @ 2:25 pm

 

October 6, 2011

 Using Nginx as reverse IMAP/POP Proxy

This document covers the steps you need to take to have Atmail working with the NginX platform.

Nginx is a free, open-source, high-performance HTTP server and IMAP/POP3 proxy. This is useful for environments that wish to geographically split machines into independent entities, with a central routing system that forwards a user to his/her specific server.

First, download spawn-fcgi from http://redmine.lighttpd.net/projects/spawn-fcgi/news:

% wget "http://www.lighttpd.net/download/spawn-fcgi-1.6.3.tar.gz"

Untar, install:

% tar xvfz spawn-fcgi-1.6.3.tar.gz
% cd spawn-fcgi-1.6.3
% ./configure && make && make install

Then, download nginx from http://nginx.org/en/download.html:

% wget "http://nginx.org/download/nginx-1.0.8.tar.gz"

Untar, install:

% tar xvfz nginx-0.8.40.tar.gz
% cd nginx-0.8.40
% ./configure && make && make install

This will install nginx in /usr/local/nginx/. You will then need to move the /usr/local/nginx/conf/nginx.conf file:

% mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.old
% cd /usr/local/nginx/conf

Replace the nginx.conf file with these contents:

user  atmail;
worker_processes  2;
error_log  logs/error.log  info;
pid        logs/nginx.pid;
events {
    worker_connections  1024;
    }

mail {
  auth_http  localhost:80/auth.php;
  proxy  on;
  imap_capabilities  "IMAP4rev1"  "UIDPLUS";
  server {
    listen     143;
    protocol   imap;
  }
 
  pop3_capabilities  "TOP"  "USER";
  server {
    listen     110;
    protocol   pop3;
  }
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  10;

server {
    # Your server's IP address. Leave as an asterisk to bind to all interfaces
    listen       *:80;
    # Your domain name
    server_name  domain.com;      
    location / {
    # Path to your Atmail webmail directory
        root   /usr/local/atmail/webmail/;  
        index  index.php;
        # this serves static files that exist without running other rewrite tests
        if (-f $request_filename) {
            expires 30d;
            break;
        }
    # Routes directory requests to index.php.
        if (!-e $request_filename) {
            rewrite ^(.+)$ /index.php?q=$1 last;
        }
    }

    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:34480;  # IP and Port of your spawn-fcgi process
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME    /usr/local/atmail/webmail/$fastcgi_script_name;
        fastcgi_param  QUERY_STRING       $query_string;
        fastcgi_param  REQUEST_METHOD     $request_method;
        fastcgi_param  CONTENT_TYPE       $content_type;
        fastcgi_param  CONTENT_LENGTH     $content_length;
        fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
        fastcgi_param  REQUEST_URI        $request_uri;
        fastcgi_param  DOCUMENT_URI       $document_uri;
        fastcgi_param  DOCUMENT_ROOT      $document_root;
        fastcgi_param  SERVER_PROTOCOL    $server_protocol;
        fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
        fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;
        fastcgi_param  REMOTE_ADDR        $remote_addr;
        fastcgi_param  REMOTE_PORT        $remote_port;
        fastcgi_param  SERVER_ADDR        $server_addr;
        fastcgi_param  SERVER_PORT        $server_port;
        fastcgi_param  SERVER_NAME        $server_name;
        fastcgi_param  REDIRECT_STATUS    200;
    }
}
}

Spawn the FastCGI process afterwards. For this example, we will run it in port 34480:

% /usr/local/bin/spawn-fcgi -f /usr/bin/php-cgi -a 127.0.0.1 -p 34480 -P /var/run/fastcgi-php.pid -C 2

You will then need to edit the /usr/local/nginx/conf/nginx.conf file. It will contain this line:

fastcgi_pass   127.0.0.1:34480;  # IP and Port of your spawn-fcgi process

If you change the spawn-fcgi port, you will need to edit it in the nginx.conf file as well. For example, a spawn-fcgi port of 51000 will have this command:

/usr/local/bin/spawn-fcgi -f /usr/bin/php-cgi -a 127.0.0.1 -p 51000 -P /var/run/fastcgi-php.pid -C 2

And this configuration line:

fastcgi_pass   127.0.0.1:51000;  # IP and Port of your spawn-fcgi process

The configuration file will also contain the following lines of interest:

root   /usr/local/atmail/webmail/;

This defines the document root you wish to have.

user  atmail;

This defines the username you want to run nginx as.

worker_processes  2;

This sets the number of processes that nginx spawns. We recommend it to be set to the number of CPU cores you have available.

Note the document root specified above (in this case, /usr/local/atmail/webmail/). Create the authentication php file at /usr/local/atmail/webmail/auth.php, and fill it with these lines:

$username=$_SERVER["HTTP_AUTH_USER"] ;
$userpass=$_SERVER["HTTP_AUTH_PASS"] ;
$protocol=$_SERVER["HTTP_AUTH_PROTOCOL"] ;

$backend_port=110;
if ($protocol=="imap") {
$backend_port=143;
}
if ($protocol=="smtp") {
$backend_port=25;
}

if (!authuser($username,$userpass)) {
fail();
exit;
}

$userserver=getmailserver($username);
pass($userserver, $backend_port);

// Authentication block
function authuser($user,$pass)
{
// You can put a query for authentication with the DB here.
// Since auth will be done post-proxy, we're just returning true
return true;
}

// MySQL connection function
function mysqlconn($user,$query){
$atmail_dbuser="atmail";
$atmail_dbpass="changeme";
$atmail_db="nginx_map";
$atmail_dbhost="127.0.0.1";

mysql_connect($atmail_dbhost,$atmail_dbuser,$atmail_dbpass);
@mysql_select_db($atmail_db) or die( "Unable to select database");

$server1 = mysql_query($query);

$server = mysql_fetch_array($server1);
$server2 = $server['Server'];
return $server2;
mysql_close();

}

function getmailserver($user){
$query = "select Server from UserMap where Account='$user'";
$server = mysqlconn($user,$query);
return $server;
mysql_close();

}

function fail(){
header("Auth-Status: Invalid login or password");
exit;
}

function pass($server,$port){
header("Auth-Status: OK");
header("Auth-Server: $server");
header("Auth-Port: $port");
exit;
}

Save the file. After it is created, login to MySQL:

% mysql -u [dbuser] -p

Specify [dbuser] as your MySQL root user. Create the database (in this case, nginx_map, with the user 'atmail', the password 'changeme' and the host '127.0.0.1'):

> create database nginx_map;
> grant all privileges on nginx_map.* to 'atmail'@'localhost' identified by 'changeme';
> grant all privileges on nginx_map.* to 'atmail'@'127.0.0.1' identified by 'changeme';
> flush privileges;

Create the database skeleton:

CREATE TABLE `UserMap` (
`Account` varchar(255) NOT NULL default '',
`Server` varchar(255) NOT NULL default '',
PRIMARY KEY  (`Account`) );
);

You can create preliminary entries like so:

> insert into UserMap values("john@juno.com","192.168.0.71");

This will forward the user 'john@juno.com' to the IMAP host at '192.168.0.71'.

When you are satisfied, run the nginx process:

% /usr/local/nginx/sbin/nginx

To test it out, login locally with your sample user:

% telnet localhost 143
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
* OK IMAP4 ready
1 login john@juno.com changeme
1 OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS QUOTA] Logged in

Congratulations! Now you can set your Nginx process as a forwarding proxy for IMAP and POP requests. This is useful for very large installations that wish to install Atmail as a geographically separated cluster install.


Filed under: Uncategorized — John Contad @ 7:01 pm

 

April 17, 2011

 Using Unison with Atmail

Unison allows two replicas of a collection of files and directories to be stored on different hosts (or different disks on the same host), modified separately, and then brought up to date by propagating the changes in each replica to the other. In other words, it can be used for two-way synchronization between your servers.

For illustrative purposes in this example, the Unison Master hostname will be called "master-foo-01"; the Client hostname will be called "slave-foo-02".

To setup Unison on your machine, do the following for both machines:

1.) Download the dependency, OCaml from: http://caml.inria.fr/download.en.html

atmail@master-foo-01# wget "http://caml.inria.fr/pub/distrib/ocaml-3.12/ocaml-3.12.0.tar.gz"

2.) Install emacs (a dependency):

atmail@master-foo-01# yum install emacs

3.) Unpack, install OCaml:

atmail@master-foo-01# tar xvfz ocaml-3.12.0.tar.gz
atmail@master-foo-01# cd ocaml-3.12.0
atmail@master-foo-01# ./configure && make world
atmail@master-foo-01# make opt
atmail@master-foo-01# make install

4.) Download Unison from: http://www.cis.upenn.edu/~bcpierce/unison/download.html

atmail@master-foo-01# wget "http://www.seas.upenn.edu/~bcpierce/unison//download/releases/stable/unison-2.40.63.tar.gz"

5.) Untar, install:

atmail@master-foo-01# make world opt
atmail@master-foo-01# sudo make install

6.) Move the Unison binary to your preferred prefix. We suggest /usr/bin/:

atmail@master-foo-01# mv unison /usr/bin/unison
atmail@master-foo-01# chmod 755 /usr/bin/unison

7.) You will then need to set the keys. Create a SSH public key on the Master server:

atmail@master-foo-01# ssh-keygen -t rsa

8.) This will produce a public key in /home/atmail/.ssh/id_rsa.pub. Copy the .pub file to the Slave machine:

atmail@master-foo-01# scp /home/atmail/.ssh/id_rsa.pub root@slave-foo-02:/home/atmail/.ssh/id_rsa.pub

9.) Pipe the public key into a file called authorized_keys, in your .ssh directory.

atmail@slave-foo-02# cat /home/atmail/.ssh/id_rsa.pub >> authorized_keys

10.) Make sure that the authorized_keys file, and all of the contents of the .ssh directory have 600 permissions:

atmail@slave-foo-02# chmod 600 /home/atmail/.ssh/*

11.) Try to login, sans password, from the Master machine to the Client machine.

atmail@master-foo-01# ssh atmail@slave-foo-02

12.) This should allow you to login. Now, you can try to sync the differences between the users/ directory of the master and slave machines. From any of the machines, execute:

atmail@master-foo-01# unison -batch -auto /usr/local/atmail/users ssh://slave-foo-01//usr/local/atmail/users

13.) The output should be similar to:

UNISON 2.40.63 finished propagating changes at 01:25:25.57 on 18 Apr 2011
Saving synchronizer state
Synchronization complete at 01:25:25  (xx items transferred, 0 skipped, 0 failed)

14.) You will need to set this in cron. Create a file called /home/atmail/unison.sh. In the file:

#!/bin/sh
/usr/bin/unison -batch -auto /usr/local/atmail/users ssh://slave-foo-01//usr/local/atmail/users

15.) Set permissions:

% chmod 755 /home/atmail/unison.sh

16.) Add an entry to your /etc/crontab. It will look like:

01,10,20,30,40,50 * * * * atmail /home/atmail/unison.sh

This will synchronize your /usr/local/atmail/users directory for both machines.


Filed under: Uncategorized, Multiserver, OS, Atmail 5, Atmail 6 — John Contad @ 10:13 pm

 

February 17, 2011

 Upgrading to SpamAssassin 3.3.x

The newer version of SpamAssassin contains many upgrades - up to, and including DKIM checks, an improved SQL settings implementation. You may want to upgrade to this version.

Upgrading is easy; just go through the following steps:

1.) Download SpamAssassin from: http://spamassassin.apache.org/downloads.cgi

% wget "http://apache.mirror.aussiehq.net.au//spamassassin/source/Mail-SpamAssassin-3.3.1.tar.gz"

2.) Unpack:

% tar xvfz Mail-SpamAssassin-3.3.1.tar.gz -C /usr/local/atmail/server_source/
% cd /usr/local/atmail/server_source/Mail-SpamAssassin-3.3.1


3.) Rename your previous SpamAssassin directory:

% mv /usr/local/atmail/spamassassin /usr/local/atmail/spamassassin.3.2

4.) Install the NetAddr::IP module:

% perl -MCPAN -e 'install NetAddr::IP'

5.) Install:

% perl Makefile.PL  PREFIX=/usr/local/atmail/spamassassin/  && make && make install

6.) Move the local.cf and sqlsettings.cf files:

% cp /usr/local/atmail/spamassassin.3.2/etc/sqlsettings.cf /usr/local/atmail/spamassassin.3.2/etc/local.cf /usr/local/atmail/spamassassin/etc/mail/spamassassin/

7.) Restart services:

% /etc/init.d/atmailserver restart

Congratulations. Now you have SpamAssassin 3.3.x. Credits to the Apache Software Foundation (http://www.apache.org/) for making a tremendously amazing piece of software.


Filed under: Uncategorized, Anti-Spam — John Contad @ 8:32 pm

 

February 16, 2011

 Running IMAP on Another Port

To run Dovecot on another port, just do the following:

Open up /usr/local/atmail/mailserver/etc/dovecot.conf. Find:

protocol imap {
#
mail_plugins = quota imap_quota
#
#  mail_executable = /usr/local/atmail/mailserver/etc/create-imap.sh
#

}

Change to:

protocol imap {
#
mail_plugins = quota imap_quota
#
#  mail_executable = /usr/local/atmail/mailserver/etc/create-imap.sh
#

listen = *:143 *:144

}

Where 144 is your additional port. Restart Atmail afterward.


Filed under: Uncategorized — John Contad @ 4:14 pm

 

January 20, 2011

 Logrotate for Atmail 6 logs

Configuring Logrotate is critical, so as to reduce the size of the files used by Atmail in the webmail/log directory. To implement logrotate for your server, please do the following:

- create a file in /etc/logrotate.d/ called 'logrotate_atmail_log'

- in the file, put:
/usr/local/atmail/webmail/log/*log {
    missingok
    notifempty
    sharedscripts
    postrotate
/etc/init.d/atmailserver restart >/dev/null 2>&1 || true
    endscript
}
- start logrotate:

% /usr/sbin/logrotate /etc/logrotate.conf

This will then manually execute the log rotation process.


Filed under: Uncategorized — John Contad @ 9:38 pm

 

January 18, 2011

 new MailRelay table for mysql replication

If your slave MySQL is out of sync with your primary MySQL, please do the following via MySQL command prompt.

drop table MailRelay;

CREATE TABLE `MailRelay` (
`IPaddress` varchar(16) NOT NULL default '',
`DateAdded` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`Account` varchar(128) default NULL,
`id` bigint(20) unsigned NOT NULL auto_increment,
PRIMARY KEY (`id`),
KEY `DateAdded` (`DateAdded`),
KEY `IPaddress` (`IPaddress`),
KEY `Account` (`Account`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


Filed under: Uncategorized — Stewart Bazley @ 2:49 pm

 

December 22, 2010

 Enlarging PDF thumbnails

Atmail renders PDF attachments inline as a PNG image. By default the thumbnail width is 300 pixels, showing a quick snapshot of the content of the PDF.

Should you wish to expand the width of the inline PDF previews edit

webmail/application/modules/mail/plugins/Atmail/FilePreview/Plugin.php 

Locate the following in function _createPdfPreview:

-thumbnail x300

And replace with:

-thumbnail x700

Save the file, and reload Atmail. All PDF thumbnails will be scaled to 700 pixels, providing a far larger preview of the PDF content. Example below

large-snapshot.png


Filed under: Uncategorized — info @ 12:59 am