<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://blog.effraie.org/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
  <title>Effraie@blog - Balise - Postfix</title>
  <link>http://blog.effraie.org/</link>
  <atom:link href="http://blog.effraie.org/feed/tag/Postfix/rss2" rel="self" type="application/rss+xml"/>
  <description></description>
  <language>fr</language>
  <pubDate>Mon, 01 Dec 2008 23:12:11 +0100</pubDate>
  <copyright>WTFPL</copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>Postfix, Dovecot, et des utilisateurs virtuels sans Mysql</title>
    <link>http://blog.effraie.org/post/2008/06/11/Postfix-Dovecot-et-des-utilisateurs-virtuels-sans-Mysql</link>
    <guid isPermaLink="false">urn:md5:d96a8452980bc8cc1b1b8e9ad9231b65</guid>
    <pubDate>Wed, 11 Jun 2008 00:27:00 +0200</pubDate>
    <dc:creator>effraie</dc:creator>
        <category>Dovecot</category><category>Geek</category><category>Liberté</category><category>Linux</category><category>Logiciel</category><category>Mail</category><category>Postfix</category><category>Serveur</category><category>Web</category>    
    <description>    &lt;p&gt;&lt;strong&gt;par souci de lisibilité et de référencement, j'ai finalement scindé &lt;a href=&quot;http://blog.effraie.org/post/2008/06/09/mv-flickr-/dev/null-postfix-virtuals2&quot;&gt;mon précédent billet&lt;/a&gt; en deux: un sujet, un billet.&lt;/strong&gt;&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://blog.effraie.org/public/mysza.gif&quot; alt=&quot;postfix&quot; style=&quot;float:right; margin: 0 0 1em 1em;&quot; /&gt;Un petit mémo sur la façon de configurer &lt;a href=&quot;http://www.postfix.org/&quot;&gt;postfix&lt;/a&gt; et &lt;a href=&quot;http://www.dovecot.org/&quot;&gt;dovecot&lt;/a&gt; pour héberger des domaines de mail multiples et virtuels, le tout sur une seule et même installation, sans passer par l'usine à gaz qu'est MySql (enfin, tant que vous n'avez pas des milliers d'utilisateurs)
&lt;br /&gt; &lt;br /&gt;&lt;/p&gt;

&lt;h3&gt;Dans postfix&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;main.cf, la section qui autorise les domaines virtuels est la suivante:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;bash&quot;&gt;virtual_mailbox_domains = &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;hash&lt;/span&gt;:&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;postfix&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;vdomains
virtual_mailbox_base = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;home&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;vmail
virtual_mailbox_maps = &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;hash&lt;/span&gt;:&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;postfix&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;vmailbox
virtual_uid_maps = &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;hash&lt;/span&gt;:&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;postfix&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;virtual_uids
virtual_gid_maps = &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;hash&lt;/span&gt;:&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;postfix&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;virtual_gids
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;### 200 Mo ( a peu pres )&lt;/span&gt;
virtual_mailbox_limit = &lt;span style=&quot;color: #000000;&quot;&gt;200000000&lt;/span&gt;
local_recipient_maps    = proxy:unix:&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;passwd&lt;/span&gt;.byname &lt;span style=&quot;color: #007800;&quot;&gt;$alias_maps&lt;/span&gt; &lt;span style=&quot;color: #007800;&quot;&gt;$virtual_mailbox_maps&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;em&gt;N'oubliez pas de postmaper les fichiers qui sont indiqués après hash:/ !!&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;vdomains est de la forme:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;bash&quot;&gt;domain1.tld    pouet
domain2.tld    pouet
domain3.tld    pouet&lt;/pre&gt;


&lt;ul&gt;
&lt;li&gt;vmailbox est de la forme:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;bash&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#user@domain         domain/user/&lt;/span&gt;
user1&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;domain1.tld    domain1.tld&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;user1&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;
user2&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;domain2.tld     domain2.tld&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;user2&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;virtuals_uids et virtual_gids sont de la forme:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;bash&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#virtuals_gids&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#grep -i vmail /etc/group&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#@tutu.com   5000 (pour vmail)&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#####################&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;domain1.tld    &lt;span style=&quot;color: #000000;&quot;&gt;5000&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;domain2.tld    &lt;span style=&quot;color: #000000;&quot;&gt;5000&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;C'est tout dans postfix. Il faut créer un utilisateur qui accédera aux Maildir. J'ai choisi de créer un user system vmail, d'uid:gid 5000:5000
&lt;br /&gt; &lt;br /&gt;
Les mails seront distribués dans:
&lt;code&gt;/home/vmail/domain1.tld/user1/&lt;/code&gt; &lt;br /&gt;
Maintenant, nous devons permettre aux utilisateurs d'accéder à ces boites emails, et ça va être le travail de dovecot &lt;strong&gt;(best imap server ever!)&lt;/strong&gt; &lt;br /&gt; &lt;br /&gt;&lt;/p&gt;


&lt;h3&gt;Dans dovecot&lt;/h3&gt;


&lt;p&gt;La configuration de dovecot, comme d'habitude, est hyper simple:&lt;/p&gt;

&lt;pre class=&quot;perl&quot;&gt;protocols = imaps
&lt;span style=&quot;color: #000066;&quot;&gt;listen&lt;/span&gt; = &lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt;
disable_plaintext_auth = yes
log_path = &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;var&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000066;&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;dovecot&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;dovecot.&lt;span style=&quot;color: #000066;&quot;&gt;log&lt;/span&gt;
info_log_path=&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;var&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000066;&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;dovecot&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;dovecot.&lt;span style=&quot;color: #000066;&quot;&gt;log&lt;/span&gt;
log_timestamp = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;%Y-%m-%d %H:%M:%S &amp;quot;&lt;/span&gt;
login_greeting = ready....
auth default &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
    mechanisms = plain cram-md5
    user = root
    userdb passwd-file &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
        args = &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;dovecot&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;dovecot.users
        &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#fallback to PAM&lt;/span&gt;
    userdb passwd &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
        passdb passwd-file &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
            args = &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;dovecot&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;dovecot.users
            &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#fallback to PAM&lt;/span&gt;
        passdb pam &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
            &lt;span style=&quot;color: #000066;&quot;&gt;socket&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;listen&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
                client &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
                    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Assuming the default Postfix $queue_directory setting&lt;/span&gt;
                    path = &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;var&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;spool&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;postfix&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;private&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;auth
                    mode = &lt;span style=&quot;color: #cc66cc;&quot;&gt;0660&lt;/span&gt;
                    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Assuming the default Postfix user and group&lt;/span&gt;
                    user = postfix
                   group = postfix
                   &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
mail_extra_groups = mail
protocol imap &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
protocol pop3 &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
dict &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
plugin &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Le &lt;em&gt;fallback vers PAM&lt;/em&gt; me permet de supporter une phase de transition depuis des utilisateurs systèmes vers des utilisateurs virtuels, mais va disparaître sous peu. &lt;br /&gt;
Le truc important ici, c'est le fichier &lt;code&gt;/etc/dovecot/dovecot.users&lt;/code&gt;, qui est en fait notre table de correspondance user, password, chemin vers le Maildir. &lt;br /&gt;
Il est de la forme:&lt;/p&gt;
&lt;pre&gt;
user1@domain1.tld:{HMAC-MD5}12999732f70a30191be8c552bff077b3876d7a1fe89b9e61389b941ab598cf15:5000:5000::::userdb_mail=maildir:/home/vmail/domain1.tld/user1/
user2@domain2.tld:{HMAC-MD5}a91cbc2e844e773e464eb76786cebd6edd0c7baf5d64de09c8a4ed67851e961e:5000:5000::::userdb_mail=maildir:/home/vmail/domain2.tld/user2/
&lt;/pre&gt;


&lt;p&gt;les passwords sont &lt;em&gt;salés&lt;/em&gt; en HMAC-MD5 (ce qui n'est pas de la grande cryptographie, entendons nous bien, mais inutile de &lt;em&gt;casser&lt;/em&gt; ceux là, ce sont des fakes), et générés avec la commande: &lt;br /&gt;
&lt;code&gt;dovecotpw -p le_mot_de_passe&lt;/code&gt; &lt;br /&gt; &lt;br /&gt;
Bien sur, c'est fastidieux à faire à la main, alors &lt;a href=&quot;http://vrac.effraie.org/prog/add-mail-user&quot;&gt;voici un petit script qui ajoute un email&lt;/a&gt; de façon entièrement automatisée (lancez le script en root, répondez aux questions (nom, domaine, et mot de passe) et voila). Si par hasard vous vous en serviez (il est probablement très laid!), pensez à le lire, a comprendre ce qu'il fait, et à l'adapter à vos besoins, bien sur.&lt;/p&gt;

&lt;pre class=&quot;perl&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#!/usr/bin/perl&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;use&lt;/span&gt; strict;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;use&lt;/span&gt; POSIX;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#script sous licence WTFPL http://sam.zoy.org/wtfpl/&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# mathieu - http://blog.effraie.org/&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#Créer un email pour un utilisateur&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#tester que le script est lancé avec les droits root&lt;/span&gt;
&lt;span style=&quot;color: #b1b100;&quot;&gt;my&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$uid&lt;/span&gt; = getuid&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$uid&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;!&lt;/span&gt;= &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span style=&quot;color: #000066;&quot;&gt;print&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Vous devez etre root pour lancer ce script.&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;;
    &lt;span style=&quot;color: #000066;&quot;&gt;exit&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#récupérer le nom, le domaine, le pass&lt;/span&gt;
&lt;span style=&quot;color: #000066;&quot;&gt;print&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Nom du nouvel utilisateur mail:&amp;quot;&lt;/span&gt; . &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;;
&lt;span style=&quot;color: #b1b100;&quot;&gt;my&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$name&lt;/span&gt; = &lt;span style=&quot;color: #009999;&quot;&gt;&amp;lt;STDIN&amp;gt;&lt;/span&gt;;
&lt;span style=&quot;color: #000066;&quot;&gt;chomp&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$name&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #000066;&quot;&gt;print&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Domaine du nouveau mail:&amp;quot;&lt;/span&gt; . &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;;
&lt;span style=&quot;color: #b1b100;&quot;&gt;my&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$domain&lt;/span&gt; = &lt;span style=&quot;color: #009999;&quot;&gt;&amp;lt;STDIN&amp;gt;&lt;/span&gt;;
&lt;span style=&quot;color: #000066;&quot;&gt;chomp&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$domain&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #000066;&quot;&gt;print&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Mot de passe:&amp;quot;&lt;/span&gt; . &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;;
&lt;span style=&quot;color: #b1b100;&quot;&gt;my&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$clear_pass&lt;/span&gt; = &lt;span style=&quot;color: #009999;&quot;&gt;&amp;lt;STDIN&amp;gt;&lt;/span&gt;;
&lt;span style=&quot;color: #000066;&quot;&gt;chomp&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$clear_pass&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #b1b100;&quot;&gt;my&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$newmail&lt;/span&gt; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;$name&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\@&lt;/span&gt;$domain&amp;quot;&lt;/span&gt;;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#tests de base&lt;/span&gt;
&lt;span style=&quot;color: #000066;&quot;&gt;die&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Le nom domaine n'est pas défini.&amp;quot;&lt;/span&gt; . &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;unless&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$domain&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #000066;&quot;&gt;die&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Le nom n'est pas défini.&amp;quot;&lt;/span&gt; . &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;unless&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$name&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #000066;&quot;&gt;die&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Le mot de passe n'est pas valide.&amp;quot;&lt;/span&gt; . &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;unless&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$clear_pass&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# vérifier la validité du domaine&lt;/span&gt;
&lt;span style=&quot;color: #b1b100;&quot;&gt;my&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$test_domain&lt;/span&gt; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;grep $domain /etc/postfix/vdomains &amp;gt; /dev/null&amp;quot;&lt;/span&gt;;
&lt;span style=&quot;color: #000066;&quot;&gt;system&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$test_domain&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;$? &lt;span style=&quot;color: #66cc66;&quot;&gt;!&lt;/span&gt;= &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span style=&quot;color: #000066;&quot;&gt;print&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;le domaine n'est pas valide&amp;quot;&lt;/span&gt; . &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;;
    &lt;span style=&quot;color: #000066;&quot;&gt;exit&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# vérifier la validité du noveau mail&lt;/span&gt;
&lt;span style=&quot;color: #b1b100;&quot;&gt;my&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$test_mail&lt;/span&gt; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;grep $name&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\@&lt;/span&gt;$domain /etc/postfix/vmailbox &amp;gt; /dev/null&amp;quot;&lt;/span&gt;;
&lt;span style=&quot;color: #000066;&quot;&gt;system&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$test_mail&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;$? == &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span style=&quot;color: #000066;&quot;&gt;print&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Ce mail est déjà attribué&amp;quot;&lt;/span&gt; . &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;;
   &lt;span style=&quot;color: #000066;&quot;&gt;exit&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#saler le pass pour dovecot&lt;/span&gt;
&lt;span style=&quot;color: #b1b100;&quot;&gt;my&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$salted_pass&lt;/span&gt; = `dovecotpw -p &lt;span style=&quot;color: #0000ff;&quot;&gt;$clear_pass&lt;/span&gt;`;
&lt;span style=&quot;color: #000066;&quot;&gt;chomp&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$salted_pass&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#ajouter le mail dans postfix&lt;/span&gt;
`echo &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;$newmail     $domain/$name/&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;|&lt;/span&gt; tee -a &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;postfix&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;vmailbox &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; postmap &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;postfix&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;vmailbox`;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#autoriser l'user dans dovecot&lt;/span&gt;
`echo &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;$newmail:$salted_pass:5000:5000::::userdb_mail=maildir:/home/vmail/$domain/$name/&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;|&lt;/span&gt; tee -a &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;dovecot&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;dovecot.users`;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#redémarrer les services&lt;/span&gt;
`&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;init.d&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;postfix reload &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;init.d&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;dovecot restart &lt;span style=&quot;color: #cc66cc;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;dev&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;null`;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#envoyer un mail de bienvenue&lt;/span&gt;
`cat &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;home&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;effraie&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;scripts&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;welcome_mail &lt;span style=&quot;color: #66cc66;&quot;&gt;|&lt;/span&gt; mail &lt;span style=&quot;color: #0000ff;&quot;&gt;$newmail&lt;/span&gt; -&lt;span style=&quot;color: #000066;&quot;&gt;s&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Bienvenue sur $domain !&amp;quot;&lt;/span&gt;`;
&lt;span style=&quot;color: #000066;&quot;&gt;print&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;le Mail $newmail a bien été créé, avec le pass: $clear_pass&amp;quot;&lt;/span&gt; . &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;;
&lt;span style=&quot;color: #000066;&quot;&gt;exit&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/pre&gt;


&lt;p&gt;&lt;br /&gt; &lt;br /&gt;
Voila voila, ça n'a rien d'un tutoriel, c'est juste un petit mémo perso que je partage, dans l'hypothèse ou il puisse servir à quelqu'un (moi ça m'aurait bien aidé, heureusement, il y a &lt;a href=&quot;http://blog.uggy.org/&quot;&gt;Uggy&lt;/a&gt;). &lt;br /&gt; &lt;br /&gt;
Vos commentaires, sur la méthode, le script ou n'importe quoi d'autre, sont les bienvenus.
&lt;br /&gt; &lt;br /&gt;&lt;/p&gt;</description>
    
    
    
          <comments>http://blog.effraie.org/post/2008/06/11/Postfix-Dovecot-et-des-utilisateurs-virtuels-sans-Mysql#comment-form</comments>
      <wfw:comment>http://blog.effraie.org/post/2008/06/11/Postfix-Dovecot-et-des-utilisateurs-virtuels-sans-Mysql#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.effraie.org/feed/rss2/comments/173</wfw:commentRss>
      </item>
    
</channel>
</rss>