Zarafa Configuration: Difference between revisions
Created page with "{| border="0" |- valign="top" | <br> Zarafa | '''Zarafa QPKG Features:'''<br> {| width="100%" cellspacing="1" cellpadding="1" border="0" |- | width=..." |
|||
Line 621: | Line 621: | ||
<br> | <br> | ||
[[Category:Zarafa| ]] |
Latest revision as of 18:08, 26 October 2015
-
Zarafa Webaccess: E-Mail
-
Calendar in Zarafa Webaccess
-
Contacts in Zarafa Webaccess
Overview
This page describes how to install the Zarafa QPKG on your QNAP Device. Additional information may be found in the support forum and in the official documentation.
What is Zarafa?
Zarafa - is a Open Source Email & Collaboration Software. Store all your contacts / emails / notes / task on your QNAP device. It has a powerful webfrontend (Outlook Webaccess alike) and provides Active Sync Support to easily connect mobile devices. It acts like a exchange server to Microsoft Outlook (sync all contacts / task etc.). POP3 and IMAP connections are also possible.
To send and receive emails, it is necessary to setup postfix / fetchmail (included in the QPKG).
If you want to compile Zarafa (not recommended / needed) instead of using the QPKG look at this howto: Zarafa Installation On QNAP
What does the QPKG (currently) include?
- Zarafa ZCP 7.0.3
- Z-Push 1.5.5 (for Active Sync support)
- Licensed for Zarafa (only x86)
- Postfix 2.8.7
- Fetchmail 6.3.21
Setup Types
Depending on your current situation you can setup zarafa in many different ways. Two setup / configurations are described here. You can access Zarafa via many different ways:
- with Microsoft Outlook
- via Active Sync with your Smarphone
- via Zarafa Webaccess
- via POP3/IMAP Gateway of Zarafa
Zarafa with postfix and own domain
In this setup you have your own domain (like myemailadress@mydomain.com). Postfix has to be configured to send and receive emails. Zarafa sends emails to postfix, and receives emails from postfix.
Zarafa with postfix and fetchmail for POP3 / IMAP mailboxes
In this setup you have a email address from a provider (like myemailaddress@yahoo.com etc.). In this configuration fetchmail receives you email from the providers pop3/imap mailbox and delivers it to Zarafa. Zarafa sends emails to postfix which delivers it to your providers SMTP Server.
Installing the QPKG
Most of the install is done in the QNAP webinterface
Prerequisites
Make sure that you have a x86 or ARM-X19 based QNAP device. The Zarafa QPKG is reported to work on: TS219P+ / TS239 / TS259 Pro+ / TS659 Pro. It should work on the QNAP devices with firmware 3.5.x or greater.
Install Optware
Setup/Enable Webserver
(make sure that SSL is enabled for Z-Push/ActiveSync support)
Setup/Enable Mysql Server
Simply enable the Mysql Server
Download and Install Zarafa QPKG
You can download the latest QPKG from the Zarafa Community Hub. Select the correct release (x86/ARM-X19), download and extract the ZIP file on your computer. Then go to the webinterface under Application Servers => QPKG Plugins and select Installation
It can take up to 2 minutes to install Zarafa.
After that you can enable the Zarafa QPKG:
Zarafa Webaccess
The webaccess is available under: http://YOURNASIP/webaccess
Configure Zarafa
The configuration of Zarafa is done via SSH.
Create Zarafa Users
zarafa-admin -c <username> -P -e <email> -f "<full name>" zarafa-admin -l zarafa-admin --details <username>
Zarafa Configuration files
The Zarafa Configuration files are located in:
/etc/zarafa/
View logfiles
The logfiles are located under /var/log/zarafa/
To view the logfile of the zarafa server type in:
tail /var/log/zarafa/server.log
Starting / Stopping Zarafa
Start:
/etc/init.d/Zarafa.sh start
Stop:
/etc/init.d/Zarafa.sh stop
Restart:
/etc/init.d/Zarafa.sh restart
Postfix / Fetchmail Configuration
Postfix can be used in various scenarios (Mailserver for a single domain, postfix with smarthost and getting mails from POP3/IMAP with fetchmail).
This document currently describes the following configuration:
- Postfix with smarthost and fetchmail for receiving mails from POP3/IMAP mailboxes
- Postfix with your own domain (without user database)
- Postfix with your own domain (virtual user database)
- Postfix with your own domain (mysql zarafa user database)
Please look in the configuration description for the advantages. Usually the local user database configuration option should do the job. Please note also that you have to configure the MX records of your domain to point to your QNAP device. The port 25 is also needed to be forwarded when you want to use postfix with your own domain. More information about postfix information can be found here or in the official Zarafa and postfix documentation.
Prerequisites
Postfix and Fetchmail will be disabled by default setup. To enable them edit /etc/init.d/Zarafa.sh (you can also use vi as the editor if you want, if you want to install nano type in: ipkg install nano):
nano /etc/init.d/Zarafa.sh
And find these lines:
# Change to TRUE to enable POSTFIX or Fetchmail POSTFIX_ENABLED="FALSE" FETCHMAIL_ENABLED="FALSE"
and change them to (if you don't want to use one of them, simply don't change it :-)
# Change to TRUE to enable POSTFIX or Fetchmail POSTFIX_ENABLED="TRUE" FETCHMAIL_ENABLED="TRUE"
As QNAP does not have syslogd enabled by default and postfix logs to syslog, it is important to start syslogd once if you want to view logmessages. The syslog (with postfix messages) can be viewed in /var/log/messages
/sbin/syslogd
Configure Postfix with smarthost and fetchmail for receiving mails from POP3/IMAP mailboxes
This section describes how to configure postfix/fetchmail for the following configuration
- Emails will be received with fetchmail by using POP3/IMAP
- Fetchmail stores this emails into Zarafa
- Zarafa sends emails to postfix, which uses a smarthost/relay to deliver emails
Postfix configuration
Open the main configuration file of postfix with nano
nano /etc/postfix/main.cf
Search for the following line:
sendmail_path = /usr/sbin/sendmail
and change it to:
sendmail_path = /usr/sbin/sendmail-postfix
Please add the following configuration at the end of the file:
#Default user for postfix (this is nobody by default, QNAP NAS don't have nobody) default_privs = guest smtpd_sasl_auth_enable = yes smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination #Change SMARTHOST to the mailserver of your provider (the [] are important, do not remove them!) #Example: smtp.mail.yahoo.de relayhost = [SMARTHOST] smtp_sasl_auth_enable = yes smtp_sasl_security_options = noanonymous #This file contains the username and password of your provider smtp_sasl_password_maps = hash:/etc/postfix/saslpasswd #Uncomment the following line to get debug output in case of problems with the smarthost #debug_peer_list = SMARTHOST
Now you have to create the saslpasswd file for postfix.
nano /etc/postfix/saslpasswd
Create one line with the smarthost that you selected in the main.cf and then add the username and password of your provider.
SMARTHOST USERNAME:PASSWORD
You have to create .db files of the saslpasswd file and the aliases files, so that postfix can read it (you have to repeat this everytime you change one of these files).
Note: When you run postmap on aliases, you will get some warning messages - you can ignore them. If you get a message "postmap not found etc." try to run it with /opt/sbin/postmap or /usr/sbin/postmap. If you get a message like "libdb-4.2.so not found" check for the libdb-4.2.so file in /opt/lib and create a symbolic link in /usr/lib with 'ln -s /opt/lib/libdb-4.2.so /usr/lib/libdb-4.2.so'.
postmap /etc/postfix/saslpasswd postmap /etc/postfix/aliases
Now it is time to test the configuration.
/etc/init.d/Zarafa.sh restart
Now you can view the postfix logfile. Try to send a email from zarafa webaccess.
tail -f /var/log/messages
If you modified your configuration you have to restart postfix. If you want to try to resend your mails enter: postfix flush
Configure fetchmail
Fetchmail retrieves emails from POP3 and IMAP accounts. This example shows how to query a POP3 account.
nano /etc/fetchmail/fetchmailrc
# every 60 seconds fetchmail tries to download new mail set daemon 60 # Replace POP3SERVER and USERNAME with the correct values from your provider poll POP3SERVER protocol pop3 port 995 user USERNAME # Replace PASSWORD_OF_USERNAME with the password of the username password PASSWORD_OF_USERNAME ssl smtpaddress localhost # Replace ZARAFAUSER with the username of your local zarafauser where the mail shoud be delivered to. flush forcecr mda "/usr/bin/zarafa-dagent ZARAFAUSER"
You can start fetchmail with:
/etc/init.d/Zarafa.sh restart
Logfiles can be viewed with:
tail -f /var/log/fetchmail
Configure Postfix with your own domain (without user database)
Edit the file /etc/postfix/master.cf and add the zarafa part seen below:
nano /etc/postfix/master.cf
... # ========================================================================== # service type private unpriv chroot wakeup maxproc command + args # (yes) (yes) (yes) (never) (100) # ========================================================================== smtp inet n - n - - smtpd zarafa unix - n n - 10 pipe flags= user=vmail argv=/usr/bin/zarafa-dagent $(user) #smtp inet n - n - 1 postscreen ...
(Note: before flags is a whitspace!!)
Use this main.cf for postifx (modify myhostname, and mydomain and set them to your domain)
nano /etc/postfix/main.cf
# The queue_directory specifies the location of the Postfix queue. queue_directory = /var/spool/postfix # The command_directory parameter specifies the location of all # postXXX commands. command_directory = /usr/sbin # The daemon_directory parameter specifies the location of all Postfix # daemon programs (i.e. programs listed in the master.cf file). This # directory must be owned by root. daemon_directory = /usr/libexec/postfix # The data_directory parameter specifies the location of Postfix-writable # data files (caches, random numbers). This directory must be owned # by the mail_owner account (see below). data_directory = /var/lib/postfix mail_owner = postfix # DEBUGGING CONTROL # The debug_peer_level parameter specifies the increment in verbose # logging level when an SMTP client or server host name or address # matches a pattern in the debug_peer_list parameter. debug_peer_level = 2 # INSTALL-TIME CONFIGURATION INFORMATION # sendmail_path: The full pathname of the Postfix sendmail command. # This is the Sendmail-compatible mail posting interface. sendmail_path = /usr/sbin/sendmail-postfix # newaliases_path: The full pathname of the Postfix newaliases command. # This is the Sendmail-compatible command to build alias databases. newaliases_path = /usr/bin/newaliases # mailq_path: The full pathname of the Postfix mailq command. This # is the Sendmail-compatible mail queue listing command. mailq_path = /usr/bin/mailq # setgid_group: The group for mail submission and queue management # commands. This must be a group name with a numerical group ID that # is not shared with other accounts, not even with the Postfix account. setgid_group = postdrop #the hostname myhostname = MYHOSTNAME #the domain you will receive mails from mydomain = MYDOMAIN.TLD mailbox_transport = zarafa: local_recipient_maps = zarafa_destination_recipient_limit = 1 #information which domains are served by this postfix installation mydestination = $myhostname, $myhostname.local, localhost, $mydomain smtpd_recipient_restrictions = permit_mynetworks, reject_unknown_recipient_domain, permit_sasl_authenticated, reject_unauth_destination smtpd_sender_restrictions = reject_unknown_address default_privs = guest
Create a user named "vmail" (e.g. by using the QNAP administration page).
Furthermore make sure that the variable "local_admin_users" in /etc/zarafa/server.cfg contains user "vmail":
local_admin_users = admin vmail
Create a valid aliases database with postmap (ignore the warning messages)
postmap /etc/postfix/aliases
Then you can restart Zarafa with
/etc/init.d/Zarafa.sh restart
Configure Postfix with your own domain(s) (virtual user database)
In this configuration every user of zarafa who should receive emails has to be placed in a virtual userdatabase of postfix. If you add a new user to zarafa you have to modify the virtual userdatabse too.
Edit the file /etc/init.d/Zarafa.sh to enable dagent and postfix
nano /etc/init.d/Zarafa.sh
modify line 272 to enable zarafa-dagent:
#${QPKG_DIR}/etc/init.d/zarafa-dagent start
to
${QPKG_DIR}/etc/init.d/zarafa-dagent start
Use this main.cf for postfix (modify myhostname, and virtual_mailbox_domain and set them to your domain)
# The queue_directory specifies the location of the Postfix queue. queue_directory = /var/spool/postfix # The command_directory parameter specifies the location of all # postXXX commands. command_directory = /usr/sbin # The daemon_directory parameter specifies the location of all Postfix # daemon programs (i.e. programs listed in the master.cf file). This # directory must be owned by root. daemon_directory = /usr/libexec/postfix # The data_directory parameter specifies the location of Postfix-writable # data files (caches, random numbers). This directory must be owned # by the mail_owner account (see below). data_directory = /var/lib/postfix mail_owner = postfix # DEBUGGING CONTROL # The debug_peer_level parameter specifies the increment in verbose # logging level when an SMTP client or server host name or address # matches a pattern in the debug_peer_list parameter. debug_peer_level = 2 # INSTALL-TIME CONFIGURATION INFORMATION # sendmail_path: The full pathname of the Postfix sendmail command. # This is the Sendmail-compatible mail posting interface. sendmail_path = /usr/sbin/sendmail-postfix # newaliases_path: The full pathname of the Postfix newaliases command. # This is the Sendmail-compatible command to build alias databases. newaliases_path = /usr/bin/newaliases # mailq_path: The full pathname of the Postfix mailq command. This # is the Sendmail-compatible mail queue listing command. mailq_path = /usr/bin/mailq # setgid_group: The group for mail submission and queue management # commands. This must be a group name with a numerical group ID that # is not shared with other accounts, not even with the Postfix account. setgid_group = postdrop #the hostname myhostname = MYHOSTNAME virtual_mailbox_domains = EXAMPLE.NET, EXAMPLE.COM virtual_mailbox_maps = hash:/etc/postfix/virtual virtual_alias_maps = hash:/etc/postfix/virtual virtual_transport = lmtp:127.0.0.1:2003 #information which domains are served by this postfix installation mydestination = $myhostname, $myhostname.local, localhost, $mydomain smtpd_recipient_restrictions = permit_mynetworks, reject_unknown_recipient_domain, permit_sasl_authenticated, reject_unauth_destination smtpd_sender_restrictions = reject_unknown_address default_privs = guest
Next create/edit the virtual userdatabase(contains mapping between postfix and zarafa users) adapt it to your needs
nano /etc/postfix/virtual
#Emailaddress or alias primary mailaddress of zarafa user john@example.com john@example.com user1@example.com user1@example.com user1@example.net user1@example.com alias_user1@example.com user1@example.com info@example.com user2@example.com, user1@example.com
Next create the virtual.db file with postmap and create a valid aliases database with postmap (ignore the warning messages)
postmap /etc/postfix/aliases postmap /etc/postfix/virtual
Then you can restart Zarafa with
/etc/init.d/Zarafa.sh restart
Configure Postfix with your own domain (mysql zarafa user database)
In this configuration postfix queries the zarafa user database (stored in the mysql database). When you create a Zarafa user, postfix knows this automaticly.
Edit the file /etc/postfix/master.cf and add the zarafa part seen below:
nano /etc/postfix/master.cf
... # ========================================================================== # service type private unpriv chroot wakeup maxproc command + args # (yes) (yes) (yes) (never) (100) # ========================================================================== smtp inet n - n - - smtpd zarafa unix - n n - 10 pipe flags= user=vmail argv=/usr/bin/zarafa-dagent $(user) #smtp inet n - n - 1 postscreen ...
(Note: before flags is a whitspace!!)
Use this main.cf for postifx (modify myhostname, and mydomain and set them to your domain)
nano /etc/postfix/main.cf
# The queue_directory specifies the location of the Postfix queue. queue_directory = /var/spool/postfix # The command_directory parameter specifies the location of all # postXXX commands. command_directory = /usr/sbin # The daemon_directory parameter specifies the location of all Postfix # daemon programs (i.e. programs listed in the master.cf file). This # directory must be owned by root. daemon_directory = /usr/libexec/postfix # The data_directory parameter specifies the location of Postfix-writable # data files (caches, random numbers). This directory must be owned # by the mail_owner account (see below). data_directory = /var/lib/postfix mail_owner = postfix # DEBUGGING CONTROL # The debug_peer_level parameter specifies the increment in verbose # logging level when an SMTP client or server host name or address # matches a pattern in the debug_peer_list parameter. debug_peer_level = 2 # INSTALL-TIME CONFIGURATION INFORMATION # sendmail_path: The full pathname of the Postfix sendmail command. # This is the Sendmail-compatible mail posting interface. sendmail_path = /usr/sbin/sendmail-postfix # newaliases_path: The full pathname of the Postfix newaliases command. # This is the Sendmail-compatible command to build alias databases. newaliases_path = /usr/bin/newaliases # mailq_path: The full pathname of the Postfix mailq command. This # is the Sendmail-compatible mail queue listing command. mailq_path = /usr/bin/mailq # setgid_group: The group for mail submission and queue management # commands. This must be a group name with a numerical group ID that # is not shared with other accounts, not even with the Postfix account. setgid_group = postdrop #the hostname myhostname = MYHOSTNAME #the domain you will receive mails from mydomain = MYDOMAIN #alias map file which contains the information how to connect to zarafa databse virtual_alias_maps = mysql:/etc/postfix/mysql-aliases.cf #information which domains are served by this postfix installation mydestination = $myhostname, $myhostname.local, localhost, $mydomain smtpd_recipient_restrictions = permit_mynetworks, reject_unknown_recipient_domain, permit_sasl_authenticated, reject_unauth_destination smtpd_sender_restrictions = reject_unknown_address #Transport method of the mails => Zarafa dagent mailbox_transport = zarafa zarafa_destination_recipient_limit = 1 mailbox_command = /usr/bin/zarafa-dagent "$USER" default_privs = guest
Now create/edit the file /etc/postfix/mysql-aliases.cf
nano /etc/postfix/mysql-aliases.cf
# The user name and password to log into the mysql server. user = root password = admin hosts = 127.0.0.1 dbname = zarafa # For Postfix 2.2 and later The SQL query template. # See mysql_table(5) for details. query = select value from objectproperty where objectid=(select objectid from objectproperty where value='%s' limit 1) and propname='loginname';
Create a user named "vmail" (e.g. by using the QNAP administration page).
Furthermore make sure that the variable "local_admin_users" in /etc/zarafa/server.cfg contains user "vmail":
local_admin_users = admin vmail
Then create the aliases.db if not done before:
postmap /etc/postfix/aliases
Please make sure that you have enabled postfix in the file /etc/init.d/Zarafa.sh and restart zarafa
/etc/init.d/Zarafa.sh restart
Backup
Zarafa consists of three types of files:
- Program data
- Configuration data
- Mail data
Program data
Program data is the data installed by the QPKG, so if you keep a copy of the latest QPKG, you are covered.
Configuration data
Configuration data is found in /etc/component. Untill now three components are used:
- Zarafa
- Postfix
- Fetchmail
A simple backup of these folders is sufficient.
To make a backup of these folders the following commands must be used in a script:
rsync -avr /etc/zarafa/ /share/Public/Zarafa/etc/Zarafa rsync -avr /etc/fetchmail/ /share/Public/Zarafa/etc/fetchmail rsync -avr /etc/postfix/ /share/Public/Zarafa/etc/postfix
Rsync is used, because the files will be the same and the standard CP command will not overwrite an existing file on the target location, rsync is with the above syntax forced to overwrite.
The target location is the default public share of the QNAP, it is advised to keep an eye on security on the public share, or pick an alternate location.
Mail data
Mail data is the tricky one, as the mail data is stored in the MYSQL database.
To export the database, the following command needs to be executed (watch the password string, this needs to be your own password for MYSQL):
/usr/local/mysql/bin/mysqldump --single-transaction -p zarafa >/share/Public/Zarafa/zarafa.dmp --password=password
The last password needs to be replaced with your MYSQL password.
If you have chosen to store the attachments not in the database, you have to copy the attachment location also with the Rsync command.
All commands combined in one script are as follows:
rsync -avr /etc/zarafa/ /share/Public/Zarafa/etc/Zarafa rsync -avr /etc/fetchmail/ /share/Public/Zarafa/etc/fetchmail rsync -avr /etc/postfix/ /share/Public/Zarafa/etc/postfix /usr/local/mysql/bin/mysqldump --single-transaction -p zarafa >/share/Public/Zarafa/zarafa.dmp --password=password
This script should run on a daily basis in order to keep your data safe.
Now all data is placed in one tree, but it still sits on the QNAP, so QNAP dead, data lost.
To prevent data loss, the next step must be to backup the data to a secondary device, a PC for instance.
After getting the data external your Zarafa config and data is safe!
The above script does not garantee stages, all is overwritten every backup. So if you delete email and want to restore this email after a few days, this script will not help. This script does help in case of a disaster (a dead QNAP for instance)
Creating the .QPKG (for current and upcoming releases)
In this section the maintenance to the package will be described in order to keep the package "open"!