Skip to content

Commit 720cd53

Browse files
committed
Implement z-push for active-sync and autodiscover.
1 parent e32729c commit 720cd53

File tree

7 files changed

+713
-3
lines changed

7 files changed

+713
-3
lines changed

install/deb/templates/mail/apache2/default.stpl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
ServerAlias %alias
44
Alias / /var/lib/roundcube/
55
Alias /error/ %home%/%user%/web/%root_domain%/document_errors/
6+
Alias /Microsoft-Server-ActiveSync /usr/share/z-push/index.php
7+
AliasMatch (?i)/Autodiscover/Autodiscover.xml "/usr/share/z-push/autodiscover/autodiscover.php"
68
#SuexecUserGroup %user% %group%
79

810
SSLEngine on
@@ -28,6 +30,32 @@
2830
allow from all
2931
</Directory>
3032

33+
<Directory /usr/share/z-push>
34+
# Don't list a directory index, follow symlinks (maybe state dir is somewhere linked)
35+
DirectoryIndex index.php
36+
Options -Indexes +FollowSymLinks
37+
38+
# Security
39+
# Don't allow .htaccess Overrides, disallow access to files
40+
AllowOverride none
41+
<IfModule !mod_authz_core.c>
42+
Order allow,deny
43+
allow from all
44+
</IfModule>
45+
<IfModule mod_authz_core.c>
46+
Require all granted
47+
</IfModule>
48+
49+
<Files "config.php">
50+
<IfModule !mod_authz_core.c>
51+
Deny from All
52+
</IfModule>
53+
<IfModule mod_authz_core.c>
54+
Require all denied
55+
</IfModule>
56+
</Files>
57+
</Directory>
58+
3159
# Protecting basic directories:
3260
<Directory /var/lib/roundcube/config>
3361
Options -FollowSymLinks

install/deb/templates/mail/nginx/default.stpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ server {
2222
return 404;
2323
}
2424

25+
location /Microsoft-Server-ActiveSync {
26+
alias /usr/share/z-push/;
27+
28+
location ~ ^/Microsoft-Server-ActiveSync/(.*\.php)$ {
29+
alias /usr/share/z-push/$1;
30+
fastcgi_pass 127.0.0.1:9000;
31+
fastcgi_index index.php;
32+
include fastcgi_params;
33+
fastcgi_param SCRIPT_FILENAME $request_filename;
34+
}
35+
}
36+
2537
location ~ ^/(.*\.php)$ {
2638
alias /var/lib/roundcube/$1;
2739
fastcgi_pass 127.0.0.1:9000;

install/deb/zpush/imap.conf.php

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
2+
<?php
3+
/***********************************************
4+
* File : config.php
5+
* Project : Z-Push
6+
* Descr : IMAP backend configuration file
7+
*
8+
* Created : 27.11.2012
9+
*
10+
* Copyright 2007 - 2016 Zarafa Deutschland GmbH
11+
*
12+
* This program is free software: you can redistribute it and/or modify
13+
* it under the terms of the GNU Affero General Public License, version 3,
14+
* as published by the Free Software Foundation.
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU Affero General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU Affero General Public License
22+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23+
*
24+
* Consult LICENSE file for details
25+
************************************************/
26+
27+
// ************************
28+
// BackendIMAP settings
29+
// ************************
30+
31+
// Defines the server to which we want to connect
32+
define('IMAP_SERVER', 'localhost');
33+
34+
// connecting to default port (143)
35+
define('IMAP_PORT', 143);
36+
37+
// best cross-platform compatibility (see http://php.net/imap_open for options)
38+
define('IMAP_OPTIONS', '/notls/norsh');
39+
40+
41+
// Mark messages as read when moving to Trash.
42+
// BE AWARE that you will lose the unread flag, but some mail clients do this so the Trash folder doesn't get boldened
43+
define('IMAP_AUTOSEEN_ON_DELETE', false);
44+
45+
46+
// IMPORTANT: BASIC IMAP FOLDERS [ask your mail admin]
47+
// We can have diferent cases (case insensitive):
48+
// 1.
49+
// inbox
50+
// sent
51+
// drafts
52+
// trash
53+
// 2.
54+
// inbox
55+
// common.sent
56+
// common.drafts
57+
// common.trash
58+
// 3.
59+
// common.inbox
60+
// common.sent
61+
// common.drafts
62+
// common.trash
63+
// 4.
64+
// common
65+
// common.sent
66+
// common.drafts
67+
// common.trash
68+
//
69+
// gmail is a special case, where the default folders are under the [gmail] prefix and the folders defined by the user are under INBOX.
70+
// This configuration seems to work:
71+
// define('IMAP_FOLDER_PREFIX', '');
72+
// define('IMAP_FOLDER_PREFIX_IN_INBOX', false);
73+
// define('IMAP_FOLDER_INBOX', 'INBOX');
74+
// define('IMAP_FOLDER_SENT', '[Gmail]/Sent');
75+
// define('IMAP_FOLDER_DRAFT', '[Gmail]/Drafts');
76+
// define('IMAP_FOLDER_TRASH', '[Gmail]/Trash');
77+
// define('IMAP_FOLDER_SPAM', '[Gmail]/Spam');
78+
// define('IMAP_FOLDER_ARCHIVE', '[Gmail]/All Mail');
79+
80+
// Since I know you won't configure this, I will raise an error unless you do.
81+
// When configured set this to true to remove the error
82+
define('IMAP_FOLDER_CONFIGURED', true);
83+
84+
// Folder prefix is the common part in your names (3, 4)
85+
define('IMAP_FOLDER_PREFIX', '');
86+
87+
// Inbox will have the preffix preppend (3 & 4 to true)
88+
define('IMAP_FOLDER_PREFIX_IN_INBOX', false);
89+
90+
// Inbox folder name (case doesn't matter) - (empty in 4)
91+
define('IMAP_FOLDER_INBOX', 'INBOX');
92+
93+
// Sent folder name (case doesn't matter)
94+
define('IMAP_FOLDER_SENT', 'SENT');
95+
96+
// Draft folder name (case doesn't matter)
97+
define('IMAP_FOLDER_DRAFT', 'DRAFTS');
98+
99+
// Trash folder name (case doesn't matter)
100+
define('IMAP_FOLDER_TRASH', 'TRASH');
101+
102+
// Spam folder name (case doesn't matter). Only showed as special by iOS devices
103+
define('IMAP_FOLDER_SPAM', 'SPAM');
104+
105+
// Archive folder name (case doesn't matter). Only showed as special by iOS devices
106+
define('IMAP_FOLDER_ARCHIVE', 'ARCHIVE');
107+
108+
109+
110+
// forward messages inline (default true - inlined)
111+
define('IMAP_INLINE_FORWARD', true);
112+
113+
// list of folders we want to exclude from sync. Names, or part of it, separated by |
114+
// example: dovecot.sieve|archive|spam
115+
define('IMAP_EXCLUDED_FOLDERS', '');
116+
117+
118+
119+
// overwrite the "from" header with some value
120+
// options:
121+
// '' - do nothing, use the From header
122+
// 'username' - the username will be set (usefull if your login is equal to your emailaddress)
123+
// 'domain' - the value of the "domain" field is used
124+
// 'sql' - the username will be the result of a sql query. REMEMBER TO INSTALL PHP-PDO AND PHP-DATABASE
125+
// 'ldap' - the username will be the result of a ldap query. REMEMBER TO INSTALL PHP-LDAP!!
126+
// '@mydomain.com' - the username is used and the given string will be appended
127+
define('IMAP_DEFAULTFROM', '');
128+
129+
// DSN: formatted PDO connection string
130+
// mysql:host=xxx;port=xxx;dbname=xxx
131+
// USER: username to DB
132+
// PASSWORD: password to DB
133+
// OPTIONS: array with options needed
134+
// QUERY: query to execute
135+
// FIELDS: columns in the query
136+
// FROM: string that will be the from, replacing the column names with the values
137+
define('IMAP_FROM_SQL_DSN', '');
138+
define('IMAP_FROM_SQL_USER', '');
139+
define('IMAP_FROM_SQL_PASSWORD', '');
140+
define('IMAP_FROM_SQL_OPTIONS', serialize(array(PDO::ATTR_PERSISTENT => true)));
141+
define('IMAP_FROM_SQL_QUERY', "select first_name, last_name, mail_address from users where mail_address = '#username@#domain'");
142+
define('IMAP_FROM_SQL_FIELDS', serialize(array('first_name', 'last_name', 'mail_address')));
143+
define('IMAP_FROM_SQL_EMAIL', '#mail_address');
144+
define('IMAP_FROM_SQL_FROM', '#first_name #last_name <#mail_address>');
145+
define('IMAP_FROM_SQL_FULLNAME', '#first_name #last_name');
146+
147+
// SERVER: ldap server
148+
// SERVER_PORT: ldap port
149+
// USER: dn to use for connecting
150+
// PASSWORD: password
151+
// QUERY: query to execute
152+
// FIELDS: columns in the query
153+
// FROM: string that will be the from, replacing the field names with the values
154+
define('IMAP_FROM_LDAP_SERVER', 'localhost');
155+
define('IMAP_FROM_LDAP_SERVER_PORT', '389');
156+
define('IMAP_FROM_LDAP_USER', 'cn=zpush,ou=servers,dc=zpush,dc=org');
157+
define('IMAP_FROM_LDAP_PASSWORD', 'password');
158+
define('IMAP_FROM_LDAP_BASE', 'dc=zpush,dc=org');
159+
define('IMAP_FROM_LDAP_QUERY', '(mail=#username@#domain)');
160+
define('IMAP_FROM_LDAP_FIELDS', serialize(array('givenname', 'sn', 'mail')));
161+
define('IMAP_FROM_LDAP_EMAIL', '#mail');
162+
define('IMAP_FROM_LDAP_FROM', '#givenname #sn <#mail>');
163+
define('IMAP_FROM_LDAP_FULLNAME', '#givenname #sn');
164+
165+
166+
167+
// Method used for sending mail
168+
// mail => mail() php function
169+
// sendmail => sendmail executable
170+
// smtp => direct connection against SMTP
171+
define('IMAP_SMTP_METHOD', 'mail');
172+
173+
global $imap_smtp_params;
174+
// SMTP Parameters
175+
// mail : no params
176+
$imap_smtp_params = array();
177+
// sendmail
178+
//$imap_smtp_params = array('sendmail_path' => '/usr/bin/sendmail', 'sendmail_args' => '-i');
179+
// smtp
180+
// "host" - The server to connect. Default is localhost.
181+
// "port" - The port to connect. Default is 25.
182+
// "auth" - Whether or not to use SMTP authentication. Default is FALSE.
183+
// "username" - The username to use for SMTP authentication. "imap_username" for using the same username as the imap server
184+
// "password" - The password to use for SMTP authentication. "imap_password" for using the same password as the imap server
185+
// "localhost" - The value to give when sending EHLO or HELO. Default is localhost
186+
// "timeout" - The SMTP connection timeout. Default is NULL (no timeout).
187+
// "verp" - Whether to use VERP or not. Default is FALSE.
188+
// "debug" - Whether to enable SMTP debug mode or not. Default is FALSE.
189+
// "persist" - Indicates whether or not the SMTP connection should persist over multiple calls to the send() method.
190+
// "pipelining" - Indicates whether or not the SMTP commands pipelining should be used.
191+
// "verify_peer" - Require verification of SSL certificate used. Default is TRUE.
192+
// "verify_peer_name" - Require verification of peer name. Default is TRUE.
193+
// "allow_self_signed" - Allow self-signed certificates. Requires verify_peer. Default is FALSE.
194+
//$imap_smtp_params = array('host' => 'localhost', 'port' => 25, 'auth' => false);
195+
// If you want to use SSL with port 25 or port 465 you must preppend "ssl://" before the hostname or IP of your SMTP server
196+
// IMPORTANT: To use SSL you must use PHP 5.1 or later, install openssl libs and use ssl:// within the host variable
197+
// IMPORTANT: To use SSL with PHP 5.6 you should set verify_peer, verify_peer_name and allow_self_signed
198+
//$imap_smtp_params = array('host' => 'ssl://localhost', 'port' => 465, 'auth' => true, 'username' => 'imap_username', 'password' => 'imap_password');
199+
200+
201+
202+
// If you are using IMAP_SMTP_METHOD = mail or sendmail and your sent messages are not correctly displayed you can change this to "\n".
203+
// BUT, it doesn't comply with RFC 2822 and will break if using smtp method
204+
define('MAIL_MIMEPART_CRLF', "\r\n");
205+
206+
207+
// A file containing file mime types->extension mappings.
208+
// SELINUX users: make sure the file has a security context accesible by your apache/php-fpm process
209+
define('SYSTEM_MIME_TYPES_MAPPING', '/etc/mime.types');
210+
211+
212+
// Use BackendCalDAV for Meetings. You cannot hope to get that functionality working without a caldav backend.
213+
define('IMAP_MEETING_USE_CALDAV', false);
214+
215+
// If your IMAP server allows authenticating via GSSAPI, php-imap will not fall back properly to other authentication
216+
// methods and you will be unable to log in. Uncomment the following line to disable that authentication method.
217+
// Multiple methods can be specified as a comma-separated string.
218+
// define('IMAP_DISABLE_AUTHENTICATOR', 'GSSAPI');

0 commit comments

Comments
 (0)