<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JoPa.Fr &#187; PDA</title>
	<atom:link href="http://www.jopa.fr/index.php/tag/pda/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jopa.fr</link>
	<description>001100010BIDOUILLE11101010111100010LIBRE1000100111100101</description>
	<lastBuildDate>Tue, 10 Jan 2012 21:59:31 +0000</lastBuildDate>
	<language>fr</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Push Mail pour serveur Imap (local ou distant)</title>
		<link>http://www.jopa.fr/index.php/2009/08/05/push-mail-sur-serveur-imap-gmail/</link>
		<comments>http://www.jopa.fr/index.php/2009/08/05/push-mail-sur-serveur-imap-gmail/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 22:01:12 +0000</pubDate>
		<dc:creator>Jopa</dc:creator>
				<category><![CDATA[Configurations]]></category>
		<category><![CDATA[Planet-Libre]]></category>
		<category><![CDATA[Réseau]]></category>
		<category><![CDATA[Mail]]></category>
		<category><![CDATA[Messagerie]]></category>
		<category><![CDATA[PDA]]></category>
		<category><![CDATA[Serveur]]></category>
		<category><![CDATA[Téléphone]]></category>

		<guid isPermaLink="false">http://www.jopa.fr/?p=1652</guid>
		<description><![CDATA[Pour continuer la construction pas à pas de notre serveur mail (cf installation d&#8217;un serveur mail brique par brique), nous allons offrir à nos utilisateurs de terminaux Windows Mobile le luxe du &#8216;push mail&#8216; (on ne peut pas demander à tout le monde d&#8217;avoir un SmartPhone sous Androïd, ceci dit, moi, ça me plairait assez [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://www.jopa.fr/wp-content/uploads/2009/08/eb0996d725ea9ae3e95da132acafd9fc1.jpg"><img class="alignleft size-medium wp-image-1654" title="eb0996d725ea9ae3e95da132acafd9fc" src="http://www.jopa.fr/wp-content/uploads/2009/08/eb0996d725ea9ae3e95da132acafd9fc1-300x200.jpg" alt="eb0996d725ea9ae3e95da132acafd9fc" width="300" height="200" /></a>Pour continuer la construction pas à pas de notre serveur mail <a title="http://www.jopa.fr/index.php/2009/02/03/installation-dun-serveur-mail-brique-par-brique-openldap-postfix-cyrus-imap-tls-sasl-spamassassin-amavis-etc/" href="http://www.jopa.fr/index.php/2009/02/03/installation-dun-serveur-mail-brique-par-brique-openldap-postfix-cyrus-imap-tls-sasl-spamassassin-amavis-etc/">(cf installation d&#8217;un serveur mail brique par brique</a>), nous allons offrir à nos utilisateurs de terminaux <em>Windows Mobile </em>le luxe du &#8216;<em>push mail</em>&#8216;<em> </em>(on ne peut pas demander à tout le monde d&#8217;avoir un <em>SmartPhone </em>sous <a title="http://fr.wikipedia.org/wiki/Android" href="http://fr.wikipedia.org/wiki/Android"><em>Androïd,</em></a> ceci dit, moi, ça me plairait assez !).  Contrairement à une configuration classique, où le terminal interroge le serveur (en <em>Pop</em> ou <em>Imap</em>), nous allons faire en sorte que ce soit le serveur qui &laquo;&nbsp;<em>pousse</em>&nbsp;&raquo; les nouveaux mails vers le mobile.</p>
<p><span id="more-1652"></span></p>
<ul>
<li>Côté Windows Mobile, c&#8217;est &laquo;&nbsp;ActiveSync&nbsp;&raquo; qui va gérer et maintenir la connexion avec le serveur, donc rien à installer, c&#8217;est super !</li>
<li>Côté serveur, nous allons utiliser &laquo;&nbsp;Z-Push&nbsp;&raquo;, une implémentation open source du protocole ActiveSync, écrite par la société <a title="http://www.zarafaserver.de/" href="http://www.zarafaserver.de/" target="_blank">Zafara</a> (en PHP).</li>
</ul>
<p>Avant de commencer, nous aurons besoin :</p>
<ul>
<li style="text-align: justify;">D&#8217;un serveur Linux avec PHP 5 et Apache 2 installés (et accessible depuis Internet évidemment) &#8211; Pour le test, j&#8217;ai utilisé une Debian Lenny -,</li>
<li style="text-align: justify;">Un serveur IMAP (local ou distant),</li>
<li style="text-align: justify;">Dans l&#8217;optique de la configuration d&#8217;un <em>VirtualHost Apache</em>, une entrée <em>DNS</em> spécifique, c&#8217;est plus propre, mais ce n&#8217;est pas obligatoire,</li>
<li style="text-align: justify;"><a title="https://developer.berlios.de/project/showfiles.php?group_id=8963" href="https://developer.berlios.de/project/showfiles.php?group_id=8963">Les sources de Z-Push</a>,</li>
<li style="text-align: justify;">Un terminal Windows Mobile (testé avec Windows Mobile 6).</li>
</ul>
<h2>Z-Push</h2>
<p>Commençons par décompresser les sources à la racine de notre serveur web :</p>
<p><span style="color: #800000;"># tar xvzf  z-push-1.2.2.tar.gz -C /var/www/</span></p>
<p>Le répertoire <strong>/var/www/z-push/state</strong> doit être accessible en écriture par l&#8217;utilisateur Apache :</p>
<p><span style="color: #800000;"># chmod 700 /var/www/z-push/state<br />
# chown www-data:www-data /var/www/z-push/state</span></p>
<p>Editons ensuite le fichier de configuration  (<strong>/var/www/z-push/config.php</strong>)</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1652code5'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p16525"><td class="code" id="p1652code5"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">...</span>
<span style="color: #666666; font-style: italic;">// The data providers that we are using (see configuration below)</span>
    <span style="color: #000088;">$BACKEND_PROVIDER</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;BackendIMAP&quot;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">...</span>
    <span style="color: #666666; font-style: italic;">// ************************</span>
    <span style="color: #666666; font-style: italic;">//  BackendIMAP settings</span>
    <span style="color: #666666; font-style: italic;">// ************************</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Defines the server to which we want to connect</span>
    <span style="color: #666666; font-style: italic;">// recommended to use local servers only</span>
    <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'IMAP_SERVER'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'localhost'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// connecting to default port (143)</span>
    <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'IMAP_PORT'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">143</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// best cross-platform compatibility (see http://php.net/imap_open for options)</span>
    <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'IMAP_OPTIONS'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'/notls/norsh/ssl/novalidate-cert'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// overwrite the &quot;from&quot; header if it isn't set when sending emails</span>
    <span style="color: #666666; font-style: italic;">// options: 'username'    - the username will be set (usefull if your login is equal to your emailaddress)</span>
    <span style="color: #666666; font-style: italic;">//        'domain'    - the value of the &quot;domain&quot; field is used</span>
    <span style="color: #666666; font-style: italic;">//        '@mydomain.com' - the username is used and the given string will be appended</span>
    <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'IMAP_DEFAULTFROM'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// copy outgoing mail to this folder. If not set z-push will try the default folders</span>
    <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'IMAP_SENTFOLDER'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #339933;">...</span></pre></td></tr></table></div>

<p style="text-align: justify;">Les paramètres ci-dessus sont adaptés au serveur imap local. Ils peuvent être ajustés à un autre serveur. Ceci devrait fonctionner avec n&#8217;importe quel serveur IMAP.</p>
<p>Par exemple, pour <em>Gmail</em> :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1652code6'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p16526"><td class="code" id="p1652code6"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'IMAP_SERVER'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'localhost'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'IMAP_PORT'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">993</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'IMAP_OPTIONS'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'/notls/norsh/ssl/novalidate-cert'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'IMAP_DEFAULTFROM'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#41;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'IMAP_SENTFOLDER'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h2>Apache</h2>
<p style="text-align: justify;">Nous allons avoir besoin de satisfaire quelques dépendences avant d&#8217;attaquer la configuration d&#8217;<em>Apache.  Z-Push</em> a en effet besoin de quelques paquets pour pouvoir fonctionner correctement :</p>
<p><span style="color: #800000;">#  apt-get install pear php5-imap php5-mail php5-mail-mime php5-pear<br />
# pear install &#8211;alldeps Mail</span></p>
<p style="text-align: justify;">Nous avons ensuite deux alternatives :</p>
<ul style="text-align: justify;">
<li>Créer un VirtualHost afin d&#8217;accéder au serveur directement par son nom : http://z-push.mondomaine.net, (plus propre à mon sens)</li>
<li style="text-align: justify;">Ou configurer un répertoire d&#8217;un site existant : (http://mon_serveur_ou_son_ip/z-push).</li>
</ul>
<h2 style="text-align: justify;">Virtualhost</h2>
<p style="text-align: justify;">Pour créer un VirtualHost, il nous faut ajouter un fichier dans /etc/apache2/sites-available. Arbitrairement, nous allons choisir <em>z-push</em> comme nom de fichier.</p>
<p style="text-align: justify;">/etc/apache2/sites-available/z-push</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1652code7'); return false;">View Code</a> INI</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p16527"><td class="code" id="p1652code7"><pre class="ini" style="font-family:monospace;">	ServerAlias zpush.mondomaine.net
	ServerAdmin webmaster@mondomaine.net
	DocumentRoot /var/www/z-push
	Alias /Microsoft-Server-ActiveSync /var/www/z-push/index.php
&nbsp;
		Options -Indexes
		AllowOverride none
		Order allow,deny
		allow from all
		php_flag magic_quotes_gpc off
		php_flag register_globals off
		php_flag magic_quotes_runtime off
		php_flag short_open_tag on
&nbsp;
	ErrorLog /var/log/apache2/zpush-error.log
	LogLevel warn
	CustomLog /var/log/apache2/zpush-access.log combined
	ServerSignature Off</pre></td></tr></table></div>

<p style="text-align: justify;">La commande <em><strong>a2ensite</strong></em> (Apache2 Enable Site) permet de rendre le <em>VirtualHost</em> actif (équivaut à faire un lien symbolique dans<strong> /etc/apache2/sites-enabled</strong>)</p>
<p style="text-align: justify;">$ sudo a2ensite z-push<br />
$ /etc/init.d/apache2 reload</p>
<h2 style="text-align: justify;">Config par défaut ou .htaccess</h2>
<p style="text-align: justify;">La deuxième technique  consiste à ne configurer que le répertoire <em>z-push</em>, sans création d&#8217;un <em>VirtualHost</em>. Pour cela, nous ajouterons simplement les lignes suivantes dans le fichier de configuration du site par défaut (normalement <strong>/etc/apache2/sites-avaible/defaut</strong>) ou directement dans un fichier un<strong> .htaccess</strong> à la racine du site :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1652code8'); return false;">View Code</a> INI</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p16528"><td class="code" id="p1652code8"><pre class="ini" style="font-family:monospace;">	Alias /Microsoft-Server-ActiveSync /var/www/z-push/index.php
&nbsp;
		Options -Indexes
		AllowOverride none
		Order allow,deny
		allow from all
		php_flag magic_quotes_gpc off
		php_flag register_globals off
		php_flag magic_quotes_runtime off
		php_flag short_open_tag on</pre></td></tr></table></div>

<h2 style="text-align: justify;">Le mobile</h2>
<p style="text-align: justify;">La configuration du serveur étant terminée, nous pouvons tester sur un terminal. Nous allons configurer <em>ActiveSync</em> pour qu&#8217;il se connecte au serveur.</p>
<ul style="text-align: justify;">
<li>Dans ActiveSync :<span style="color: #333399;"> Menu -&gt; Configurer le serveur</span>,
<ul>
<li><strong>Adresse du serveur : </strong><span style="color: #333399;"> zpush.mondomaine.net </span> (nom du VirtualHost ou Url complète d&#8217;accès à z-push),</li>
<li>Décôcher <strong>SSL </strong>(n&#8217;est pas encore configuré sur le serveur Apache),</li>
<li><strong>Nom d&#8217;utilisateur :</strong> L&#8217;utilisateur Imap pour lequel nous voulons recevoir les mails,</li>
<li><strong>Mot de passe :</strong> Mot de passe de l&#8217;utilisateur sur le serveur Imap,</li>
<li><strong>Domaine :</strong> Domaine de messagerie,</li>
<li>Ne synchroniser que les mails : nous avons utilisé z-push pour l&#8217;Imap uniquement.</li>
</ul>
</li>
<li>La synchro devrait ensuite fonctionner. L&#8217;activation du mode Push peut se faire dans le &laquo;&nbsp;<em>Comm Manager</em>&nbsp;&raquo; en activant &laquo;&nbsp;<em><strong>Microsoft Direct Push</strong></em>&laquo;&nbsp;.</li>
</ul>
<p style="text-align: justify;">La méthode est biensûr perfectible par l&#8217;ajout du support SSL. Je ne suis pas arrivé, pour l&#8217;instant, à une solution très satisfaisante concernant ce point. A moins qu&#8217;ils ne nous soit possible de faire certifier le certificat serveur par un autorithé reconnue, il faudra importer ce cetificat sur le mobile. La chose est plutôt fastidieuse, l&#8217;option d&#8217;import n&#8217;étant pas disponible dans <em>Internet Explorer mobile</em>. Il est nécessaire de passer par un export au format xml, que l&#8217;on insère ensuite dans un fichier cab pour l&#8217;installer sur le terminal. Bref, du bon gros bricolage !</p>
<p style="text-align: justify;">
<p style="text-align: justify;">Références :<em> <a title="http://andrew.tj.id.au/activesync-for-gmail/" href="http://andrew.tj.id.au/activesync-for-gmail/" target="_blank"> http://andrew.tj.id.au/activesync-for-gmail/</a></em></p>
<p style="text-align: justify;">
]]></content:encoded>
			<wfw:commentRss>http://www.jopa.fr/index.php/2009/08/05/push-mail-sur-serveur-imap-gmail/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

