<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="https://uname.pingveno.net/blog/index.php/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># uname -a - Mot-clé - mail</title>
    <link>https://uname.pingveno.net/blog/index.php/</link>
    <atom:link href="https://uname.pingveno.net/blog/index.php/feed/tag/mail/rss2" rel="self" type="application/rss+xml" />
    <description>Le blog de uname.pingveno.net</description>
    <language>fr</language>
    <pubDate>Wed, 01 Apr 2026 16:19:15 +0200</pubDate>
    <copyright>Mathieu Pellegrin</copyright>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <generator>Dotclear</generator>
          <item>
        <title>The war on SPAM: an review of the real world tools</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2017/09/12/The-war-on-SPAM%3A-an-review-of-the-real-world-tools</link>
        <guid isPermaLink="false">urn:md5:61e3fbc7776ac7b0952799741974f844</guid>
        <pubDate>Tue, 12 Sep 2017 02:54:00 +0200</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Informatique</category>
                          <category>blacklist</category>
                  <category>dkim</category>
                  <category>dmarc</category>
                  <category>greylist</category>
                  <category>mail</category>
                  <category>rbl</category>
                  <category>server</category>
                  <category>spam</category>
                  <category>spf</category>
                <description>&lt;p&gt;Anti-spam techniques review: a few hints and tools review from my own experience.&lt;/p&gt;

&lt;p&gt;Spam mesage are very common these days, but filtering them out is not as easy as it seems. The filtering techniques have evolved at the same rate than the spammers' evasive techniques, and the risk of filtering out a legitimate message is greater than ever.&lt;/p&gt;

&lt;p&gt;It is also quite difficult to find good and up-to-date counter-measures list that anyone can implement.&lt;/p&gt;

&lt;p&gt;Here is a summary of the anti-spam strategies I used / am still using. I hope it will help you understanding today's threats, and build your own solutions.&lt;/p&gt;          &lt;h3&gt;Definitions&lt;/h3&gt;

&lt;ul&gt;
	&lt;li&gt;
	&lt;p&gt;&lt;strong&gt;MTA&lt;/strong&gt; : Mail Transport Agent : this is the software that will actually do mail delivery. It is listening on port 25 and answers to SMTP commands. Some common MTAs : Postfix, Exim. &lt;a href=&quot;https://en.wikipedia.org/wiki/Message_transfer_agent&quot;&gt;More about MTA&lt;/a&gt;.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
	&lt;p&gt;&lt;strong&gt;MX&lt;/strong&gt; : MX records are DNS entries that are identifying the server responsible for mail delivery for the domain. &lt;a href=&quot;https://en.wikipedia.org/wiki/MX_record&quot; hreflang=&quot;en&quot;&gt;More about MX records&lt;/a&gt;.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
	&lt;p&gt;&lt;strong&gt;RBL&lt;/strong&gt; : Realtime Blackhole List : a list of blacklisted IPs, that should be considered as spam sources. It is called Realtime because they are constantly updated. &lt;a href=&quot;https://en.wikipedia.org/wiki/DNSBL&quot;&gt;More about RBL&lt;/a&gt;.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
	&lt;p&gt;&lt;strong&gt;RFC&lt;/strong&gt; : Request For Comments, these are proposal for norms, some of them become norms. &lt;a href=&quot;https://en.wikipedia.org/wiki/Request_for_comments&quot;&gt;More about RFC&lt;/a&gt;.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
	&lt;p&gt;&lt;strong&gt;IPS&lt;/strong&gt; : Intrusion Protection System : these are &quot;smart firewalls&quot; that are blocking malicious requests, often based on behavioral rules. &lt;a href=&quot;https://en.wikipedia.org/wiki/Intrusion_detection_system&quot; hreflang=&quot;en&quot;&gt;More about IPS&lt;/a&gt;.&lt;/p&gt;
	&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;The goals&lt;/h3&gt;

&lt;p&gt;My personal goals on SPAM war are pretty short:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;
	&lt;p&gt;Minimum false positive: having a spam is better than missing an important mail, try keeping the &quot;permanent bashing&quot; as low as possible&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
	&lt;p&gt;Hit harder on reoffending: coming-back spammers should be slapped harder&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
	&lt;p&gt;Internet neutrality: try not to encourage big mail farm, and let fair little providers doing their business&lt;/p&gt;
	&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Available techniques&lt;/h3&gt;

&lt;h4&gt;Blacklist / Blackhole Lists&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Blacklists&lt;/strong&gt;, &lt;strong&gt;Blackhole Lists&lt;/strong&gt; (or &lt;strong&gt;RBLs&lt;/strong&gt;) are the most ancient and most common measures for reducing spam. They are still pretty accurate, but:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;It depends A LOT on the &lt;strong&gt;quality of the list&lt;/strong&gt;, trashy lists are very common and they would end up sucking resources for no result, or worse, blocking legitimate emails&lt;/li&gt;
	&lt;li&gt;They are only accurate when &lt;strong&gt;updated often&lt;/strong&gt;. I mean, very often (the R in RBL).&lt;/li&gt;
	&lt;li&gt;You &lt;strong&gt;should not use it directly on the MTA&lt;/strong&gt;, these lists are an &lt;strong&gt;aggressive&lt;/strong&gt; artefact of the past, where spam did not come from mail farms.&lt;/li&gt;
	&lt;li&gt;Very &lt;strong&gt;few are implementing IPv6&lt;/strong&gt;, I agree that IPv6 spam is quite anecdotal, but it will probably change pretty soon (believe me)&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Greylist&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Greylisting&lt;/strong&gt; is issuing a temporary &lt;strong&gt;REJECT&lt;/strong&gt; code to force the foreign server to keep the message and send it back later. It aims at increasing the &quot;cost per mail&quot; for spam farms, as they cannot &quot;hit and run&quot; as fast as before.&lt;/p&gt;

&lt;p&gt;The main culprits are that &lt;strong&gt;some providers are not implementing it well&lt;/strong&gt; (hello Facebook) and so it needs an educated whitelist to work properly.&lt;/p&gt;

&lt;p&gt;Some spammers are also re-sending the same mail several times in case of failure, looking like a legitimate mail server, and making &lt;strong&gt;Greylisting&lt;/strong&gt; inefficient.&lt;/p&gt;

&lt;p&gt;It is also hurting the fastness of the mail transmission, as the retry may occur several tens minutes after, &lt;strong&gt;slowing the mail delivery&lt;/strong&gt; with little control on delays.&lt;/p&gt;

&lt;p&gt;Also, some legitimate mail farms (hello OVH) are distributing their retry on several servers, making &lt;strong&gt;Greylisting&lt;/strong&gt; inapplicable without fully whitelisting them.&lt;/p&gt;

&lt;h4&gt;RFC compliance&lt;/h4&gt;

&lt;p&gt;Spammers are often running special softwares for their crafted emails, tightening &lt;strong&gt;RFC compliance&lt;/strong&gt; may be a good way to kick them out.&lt;/p&gt;

&lt;p&gt;It can be as simple as &lt;strong&gt;forcing an HELO on SMTP protocol&lt;/strong&gt;, or more tricky like &lt;strong&gt;checking the mail headers&lt;/strong&gt; or &lt;strong&gt;enforcing a valid reverse&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In the majority of cases, it is very efficient, but:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Some home-made servers, especially Synology or Windows servers may be blocked while they are sending legitimate email. These servers are often ran by people who doesn't know or care on how to correctly setup a mail server. These buggy setups are more common than you think, and they are often legitimate senders, who have no clue of what is wrong, and are not willing to fix it (did I mentioned banking companies?).&lt;/li&gt;
	&lt;li&gt;In the vast majority of cases, IPv6-ready servers have no reverse on their IPv6 addresses and/or the IPv6 reverse is wrong.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;SPF and DKIM&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;SPF&lt;/strong&gt; and &lt;strong&gt;DKIM&lt;/strong&gt; are anti-spoofing techniques. They does not guarantee that a mail is legitimate, but if the controls are showing an anomaly, it is very likely to be spam (or worse : scam or social engineering tentative).&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;The &lt;strong&gt;SPF&lt;/strong&gt; technique is based on IP or sending domain whitelist: the sending email domain publishes a list of servers allowed to send email, along with a hint on what is expected if it does not pass (soft or hard reject).&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;DKIM&lt;/strong&gt; is much more complex as the sending mail server has to cryptographically sign every message with a domain-specific key, which is then published in a special domain record.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;SPF&lt;/strong&gt; has been proven efficient at its beginnings, but today many spammers are just using stolen email accounts or custom domains that does not publish any &lt;strong&gt;SPF&lt;/strong&gt; records, making it less pertinent.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DKIM&lt;/strong&gt; is, like &lt;strong&gt;SPF&lt;/strong&gt;, an anti spoofing technique, and spammers may be likely to sign mails from their custom domain if it becomes a necessity. Like &lt;strong&gt;SPF&lt;/strong&gt;, a signed mail is not necessarily a clean mail. By the way, signature problems are pretty comon, and trashing an offending &lt;strong&gt;DKIM&lt;/strong&gt; may not be the right behavior: Yahoo broke a lot of mailing lists when they enforced their &lt;strong&gt;DMARC&lt;/strong&gt; policy.&lt;/p&gt;

&lt;p&gt;To conclude, &lt;strong&gt;DKIM&lt;/strong&gt; is relevant if you need to certify outgoing mails or if you are enforcing policies inside your company (to block spoofed email targeting your organisation) but it is definitely not an efficient anti-spam measure. And the recipient's servers may decide to simply ignore your painfully-configured DKIM headers.&lt;/p&gt;

&lt;h4&gt;Bayesian filters&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Bayesian filters&lt;/strong&gt; are frequency-based spam detection mechanisms. The idea is to sort out ham and spam for a short period of time, to let it &quot;learn&quot; what spam is made of, for efficient content-based detection. It has the benefit of being organisation-specific, as what is ham and what is spam may vary from one company to another (a company selling drugs may not be willing to filter out every message containing the word &quot;pill&quot;).&lt;/p&gt;

&lt;p&gt;But the learning process has to be taken seriously, and many end-users are just deleting spam instead of marking it for feeding the learning. By the way, the learning process needs IMAP folders to sort mails, and it will not work properly if all users are using POP mailboxes.&lt;/p&gt;

&lt;h3&gt;Spammers techniques&lt;/h3&gt;

&lt;p&gt;Or &quot;the today's weapons of this war&quot; .&lt;/p&gt;

&lt;p&gt;Here is a short review of the spammers techniques I know, and some counter measures.&lt;/p&gt;

&lt;h4&gt;Address guessing&lt;/h4&gt;

&lt;p&gt;Some spammers are taking random web domains from their crawling, and then try to send their mails to commonly used addresses patterns. It can be webmaster@ ; ceo@ or whatever. These are easy to spot in log files, and a well configured MTA can take counter measures to lock out these guesses. Free (French ISP) is actually implementing this: &lt;a href=&quot;http://postmaster.free.fr/index_en.html&quot; hreflang=&quot;en&quot;&gt;postmaster.free.fr/index_en.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Unfortunately, some legitimate email are sometimes sent to non existent addresses (typo, user deleted, etc) and legitimate MTA sometimes get blocked if the ban trigger is too low.&lt;/p&gt;

&lt;p&gt;Moreover, nowadays' spammers are distributing their guesses trough zombie machines to stay under triggers, making it hard to spot.&lt;/p&gt;

&lt;h4&gt;Botnets&lt;/h4&gt;

&lt;p&gt;A lot of spammers are using zombies machines to send a high amount of mail in a short amount of time. Commercial ISP are taking the problem seriously, and many are blocking or filtering port 25 on their dynamic ranges, making impossible to have a custom mail server at home, but also preventing infected machines from sending direct-to-SMTP queries.&lt;/p&gt;

&lt;h4&gt;Direct to SMTP connections, ignoring MXes&lt;/h4&gt;

&lt;p&gt;Some spammers are just scanning IP ranges and directly talking to MTA, even if these MTAs are internal and pointed by no MX records. You may think that an authoritarian firewall is the neat solution, but it may be worth collecting these feisty IPs and feed them to an IPS, to protect the network from their guesses on the real MTAs.&lt;/p&gt;

&lt;h4&gt;Fake bounces and backsquatting&lt;/h4&gt;

&lt;p&gt;Sometimes you get an Undelivered Message notice (DSN) for a mail you never sent. This is probably backsquatting.&lt;br /&gt;
Backsquatting is sending email to a buggy address with a valid &quot;from&quot; address. An incorrectly configured mailserver would reply straight away to the from address to notify the failed delivery, instead of rejecting the mail and letting the foreign server doing the dirty job.&lt;/p&gt;

&lt;p&gt;These configuration errors are pretty common, sometimes in defaut configurations or example configurations, but they can be easily avoided (look for documentation about backsquatting for your MTA, and test if your y server is vulnerable).&lt;/p&gt;

&lt;h3&gt;Real life advices&lt;/h3&gt;

&lt;p&gt;I am sorry, I don't have the magic wand to stop all Spam. A good spam fighting solution is always a combination of techniques, SpamAssassin for instance uses scoring from RBL as well as a bayesian filter and SPF checks.&lt;/p&gt;

&lt;p&gt;I think that constant monitoring is important. Not just automated monitoring, but also clever log reading and mind openness on what can be a better solution for each problem. You never know what can happen in a spammer mind, and what works today may not work tomorrow. The Internet of Things is already a game changer.&lt;/p&gt;

&lt;p&gt;I also advise you to be careful. Some decisions on our implementations may really hurt the Internet. Locking whole countries out is not without consequences, and the rise of IPv6 Internet has to be take into consideration from now.&lt;/p&gt;

&lt;p&gt;Things are often not that pretty in mail servers, the temptation is great for a default blocking policy (hello MailInBlack). But as sysadmins, it is our responsability to not abuse and not hurting the smallest actors in the market (mails not coming from big farms). That may be a big word, but in my opinion, the freedom of the Internet also count on our neutrality on mail processing.&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;</description>
        
              </item>
          <item>
        <title>SSL vs TLS vs STARTTLS</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2016/06/13/SSL-vs-TLS-vs-STARTTLS</link>
        <guid isPermaLink="false">urn:md5:6edbd0220a0b8dc911d751eb40a11ddc</guid>
        <pubDate>Mon, 13 Jun 2016 17:03:00 +0200</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Informatique</category>
                          <category>mail</category>
                  <category>serveur</category>
                  <category>ssl</category>
                  <category>starttls</category>
                  <category>tls</category>
                <description>&lt;p&gt;Cet article est une traduction libre de &lt;a href=&quot;https://www.fastmail.com/help/technical/ssltlsstarttls.html&quot;&gt;https://www.fastmail.com/help/technical/ssltlsstarttls.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;J'ai réalisé cette traduction pour fournir à mes clients une explication simple mais complète sur le pourquoi du comment de SSL/TLS/STARTTLS lors de la configuration de leur client mail.&lt;/p&gt;

&lt;p&gt;Attention, &lt;strong&gt;l'article original date de 2012&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;Définitions&lt;/h3&gt;

&lt;ul&gt;
	&lt;li&gt;
	&lt;p&gt;&lt;strong&gt;Protocole&lt;/strong&gt; : un protocole de communication est un format de données, un &quot;langage&quot; permettant à deux machine de communiquer entre elles. Les deux machines doivent être en capacité de parler le même protocole pour pouvoir échanger des données. SSL est un protocole de communication sécurisé (&quot;chiffrés&quot;), popularisé par le célèbre &quot;cadenas&quot; visible sur les pages web.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
	&lt;p&gt;&lt;strong&gt;Port&lt;/strong&gt; : un port est un numéro de service sur lequel les logiciels vous pouvoir communiquer entre eux. La plupart des numéros de port sont associés à des protocoles précis.&lt;/p&gt;
	&lt;/li&gt;
&lt;/ul&gt;          &lt;h3&gt;Introduction&lt;/h3&gt;

&lt;p&gt;Il y a souvent de la confusion autour des différents termes &lt;strong&gt;SSL&lt;/strong&gt;, &lt;strong&gt;TLS&lt;/strong&gt; and &lt;strong&gt;STARTTLS&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Transport_Layer_Security&quot;&gt;SSL et TLS&lt;/a&gt; fournissent tous deux un moyen de chiffrer le canal de communication entre deux ordinateurs (par exemple votre ordinateur et votre serveur mail). TLS est le successeur de SSL et les termes SSL et TLS sont interchangeables, à moins que vous ne fassiez référence à une version particulière du protocole.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Starttls&quot;&gt;STARTTLS&lt;/a&gt; est un moyen de prendre une connexion non chiffrée existante, et la &quot;mettre à jour&quot; vers une connexion sécurisée en utilisant SSL/TLS. Notez que même s'il contient TLS dans son nom, STARTTLS ne signifie pas que vous devez obligatoirement utiliser TLS, vous pouvez utiliser SSL.&lt;/p&gt;

&lt;h3&gt;Numéros de version SSL/TLS&lt;/h3&gt;

&lt;p&gt;La numérotation des versions du protocole est inconsistante entre SSL et TLS. Lorsque TLS a remplacé SSL comme protocole préférentiel pour les communications chiffrées, il a commencé avec une nouvelle numérotation de versions, et a également commencé à utiliser des sous-versions. L'ordre des versions des protocoles du plus ancien au plus récent est donc : SSL&amp;nbsp;v2, SSL&amp;nbsp;v3, TLS&amp;nbsp;v1.0, TLS&amp;nbsp;v1.1, TLS&amp;nbsp;v1.2.&lt;/p&gt;

&lt;p&gt;Lorsque vous vous connectez sur un port chiffré avec SSL/TLS, ou que vous utilisez STARTTLS pour convertir la connexion en connexion chiffrée, les deux systèmes vont négocier quel protocole et quelle version utiliser, en se basant ce qui a été configuré et sur ce que chaque système supporte.&lt;/p&gt;

&lt;p&gt;Le support pour SSL/TLS est &quot;virtuellement&quot; universel de nos jours, mais le support des versions est variable. Pratiquement tous les systèmes supportent SSL&amp;nbsp;v3 (à part quelques rares appareils Palm Treo &lt;a href=&quot;https://blog.fastmail.com/2009/11/18/special-ssl-hostname-for-old-clients/&quot;&gt;comme nous avons pu le constater&lt;/a&gt;). La plupart des systèmes supportent TLS&amp;nbsp;v1.0. À la date de Mai 2012, &lt;a href=&quot;https://en.wikipedia.org/wiki/Transport_Layer_Security#Web_browsers&quot;&gt;le support pour TLS&amp;nbsp;v1.1 et TLS&amp;nbsp;v1.2 est beaucoup plus restreint&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Dénomination incorrecte TLS vs STARTTLS&lt;/h2&gt;

&lt;p&gt;Pour compliquer les choses, certains logiciels de mail utilisent &lt;strong&gt;incorrectement&lt;/strong&gt; le terme TLS à la place de STARTTLS. Les plus vieilles versions de Thunderbird en particulier utilisent &quot;TLS&quot; pour dire « &lt;code&gt;utiliser STARTTLS pour chiffrer la connexion dès que possible et abandonner si STARTTLS n'est pas supporté&lt;/code&gt; » et « &lt;code&gt;TLS, si disponible&lt;/code&gt; » signifie « &lt;code&gt;utiliser STARTTLS pour chiffrer la connexion dès que possible si le serveur déclare le supporter, sinon utiliser simplement une connexion non chiffrée&lt;/code&gt; ».&lt;/p&gt;

&lt;h2&gt;Numéros de ports SSL/TLS vs plaintext/STARTTLS&lt;/h2&gt;

&lt;p&gt;Le problème du dessus est particulièrement problématique lorsque vous devez configurer des ports différents pour chaque protocole.&lt;/p&gt;

&lt;p&gt;Pour ajouter de la sécurité à certains protocoles (e.g. IMAP, POP, etc.), il a été décidé d'ajouter nativement une couche de chiffrement SSL/TLS dans le protocole. Cependant, pour identifier que le logiciel doit parler la version nativement chiffrée du protocole au lieu de la version non chiffrée, un port différent a été déclaré pour chaque protocole. Vous avez donc :&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;IMAP utilise le port &lt;code&gt;143&lt;/code&gt;, mais IMAP avec SSL/TLS utilise le port &lt;code&gt;993&lt;/code&gt;.&lt;/li&gt;
	&lt;li&gt;POP utilise le port &lt;code&gt;110&lt;/code&gt;, mais POP avec SSL/TLS utilise le port &lt;code&gt;995&lt;/code&gt;.&lt;/li&gt;
	&lt;li&gt;SMTP utilise le port &lt;code&gt;25&lt;/code&gt;, mais SMTP avec SSL/TLS utilise le port &lt;code&gt;465&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Au bout d'un moment, il a été décidé qu'utiliser deux ports pour chaque protocole était du gaspillage, et qu'à la place il devrait y avoir un seul port sur lequel commencer la communication de manière non chiffrée, puis proposer au système distant de mettre à jour vers la version chiffrée. C'est ce pour quoi STARTTLS a été créé.&lt;/p&gt;

&lt;p&gt;Il y a eu quelques problèmes avec cette proposition. Il y avait déjà des logiciels qui utilisaient les numéros de port alternatifs avec une connexion SSL/TLS native. Les logiciels clients peuvent avoir une durée de vie très longue, donc vous ne pouvez pas juste désactiver les ports chiffrés avant que tous les logiciels ne soient remplacés ou mis à jour.&lt;/p&gt;

&lt;p&gt;Des mécanismes ont été mis en place sur chaque protocole pour dire aux systèmes que le protocole non chiffré supportait STARTTLS, et qu'ils ne doivent pas essayer de se connecter avant de démarrer la négociation STARTTLS. Cela créa deux situations malheureuses :&lt;/p&gt;

&lt;ol&gt;
	&lt;li&gt;Certains logiciels ignoraient simplement l'instruction « &lt;code&gt;login désactivé jusqu'à ce que la connexion soit convertie en SSL avec STARTTLS&lt;/code&gt; » et essayaient de se connecter tout de même, envoyant leur login et mot de passe à travers la connexion non chiffrée. Même si le serveur à ce moment là rejette le login, les informations sont déjà passées en clair sur Internet.&lt;/li&gt;
	&lt;li&gt;D'autres logiciels voyaient l'annonce « &lt;code&gt;login désactivé jusqu'à conversion en SSL&lt;/code&gt; », mais ne mettaient pas à jour leur connexion automatiquement, et renvoyaient des erreurs « &lt;code&gt;mot de passe incorrect&lt;/code&gt; » à l'utilisateur, ce qui provoqua de la confusion sur ce qui était incorrect dans la configuration.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ces deux problèmes causèrent finalement d'importantes incompatibilités entre les logiciels existants, et la plupart des administrateurs systèmes continuèrent d'utiliser les connexions exclusivement non sécurisés sur le port d'origine, et les connexions SSL natives sur un port alternatif.&lt;/p&gt;

&lt;p&gt;C'est donc devenu de fait le standard que tout le monde utilise. IMAP SSL/TLS chiffré sur le port&lt;code&gt;993&lt;/code&gt; ou POP SSL/TLS chiffré sur le port &lt;code&gt;995&lt;/code&gt;. Beaucoup de sites (dont FastMail) désactive à présent le port IMAP non sécurisé (port &lt;code&gt;143&lt;/code&gt;) et le port POP non sécurisé (port &lt;code&gt;110&lt;/code&gt;) pour que les utilisateurs utilisent &lt;strong&gt;obligatoirement&lt;/strong&gt; une connexion chiffrée SSL/TLS. En désactivant les ports &lt;code&gt;143&lt;/code&gt; et &lt;code&gt;110&lt;/code&gt;, cela supprime également complètement STARTTLS, même en tant qu'option pour les connexions IMAP/POP.&lt;/p&gt;

&lt;h2&gt;SMTP STARTTLS comme une exception&lt;/h2&gt;

&lt;p&gt;La seule vraie exception à ce qui précède est SMTP. Cependant, c'est pour une raison différente. La plupart des logiciels email utilisent utilisaient le port &lt;code&gt;25&lt;/code&gt; pour soumettre des messages à envoyer au serveur mail. Cependant, SMTP a été créé à l'origine comme un protocole d'échange de messages, et non de soumission. Un autre port (587) a donc été &lt;a href=&quot;https://tools.ietf.org/html/rfc2476&quot;&gt;déclaré pour la soumission de messages&lt;/a&gt;. Bien que le port &lt;code&gt;587&lt;/code&gt; ne nécessite pas explicitement STARTTLS, l'utilisation du port &lt;code&gt;587&lt;/code&gt; est devenu populaire au même moment où l'utilisation de SSL/TLS était devenue un enjeu important de sécurité et de confidentialité.&lt;/p&gt;

&lt;p&gt;Le résultat c'est que dans la plupart des cas, les systèmes qui proposent la soumission par le port &lt;code&gt;587&lt;/code&gt; &lt;strong&gt;nécessitent&lt;/strong&gt; que les logiciels utilisent STARTTLS pour chiffre la connexion, et nécessitent aussi un login et un mot de passe pour s'identifier. Il y a plusieurs avantages à cette approche. En écartant les utilisateurs du port &lt;code&gt;25&lt;/code&gt;, les FAI ont été en mesure de bloquer le port &lt;code&gt;25&lt;/code&gt; pour prévenir les envois automatiques de SPAM causés par l'infection des postes de leurs utilisateurs.&lt;/p&gt;

&lt;p&gt;Actuellement,&amp;nbsp; les choses semblent encore aléatoires, divisées entre les gens qui utilisent SMTP SSL/TLS chiffré sur le port &lt;code&gt;465&lt;/code&gt;, et les gens qui utilisent SMTP avec STARTTLS sur le port &lt;code&gt;587&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;NDLR : SMTPS sur le port &lt;code&gt;465&lt;/code&gt; est aujourd'hui &lt;a href=&quot;https://en.wikipedia.org/wiki/SMTPS&quot;&gt;définitivement obsolète&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;</description>
        
              </item>
          <item>
        <title>C'est l'histoire d'un spam Partie 1: petit cours d'anatomie</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2016/04/28/C-est-l-histoire-d-un-spam-Partie-1</link>
        <guid isPermaLink="false">urn:md5:06779a5b5e416b7931e49ff3f692ba7f</guid>
        <pubDate>Mon, 02 May 2016 15:48:00 +0200</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Informatique</category>
                          <category>mail</category>
                  <category>postfix</category>
                  <category>serie-mail-postfix-spam</category>
                  <category>spam</category>
                <description>&lt;p&gt;Le SPAM par mail, c'est pénible. C'est du travail à temps plein si on veut s'en débarrasser en gênant le moins les utilisateurs. De la stricte application des RFC aux paramètres secrets de spamassassin, je vais essayer dans cette nouvelle série d'articles essayer de vous en faire mieux comprendre les techniques, et proposer à mon échelle les quelques solutions &quot;qui marchent&quot;, du moins pour moi.&lt;/p&gt;

&lt;p&gt;Voici donc pour cette première partie un cours d'autopsie. Le SPAM que nous décortiquer aujourd'hui est un mail est est resté coincé en &lt;em&gt;queue&lt;/em&gt; sur le serveur mail. Bien que tous les mails en queue ne soient pas du SPAM, il est important de surveiller la taille de cette liste de mails &quot;en transit&quot; ; un grand nombre de mails dans cette liste indiquant souvent un problème d'envoi ou de réception.&lt;/p&gt;

&lt;p&gt;Affichons donc la queue :&lt;/p&gt;

&lt;pre&gt;
# mailq
1430281C33     8589 Thu Apr 28 14:51:58  MAILER-DAEMON
             (connect to serveurspamserveur.net.ae[86.96.xxx.xxx]:25: Connection refused)
                                         spammeur@serveurspamserveur.net.ae
&lt;/pre&gt;

&lt;p&gt;Première constatation : l'adresse source ne correspond pas à une adresse gérée par le serveur, ce n'est donc pas un mail envoyé par un des utilisateurs du serveur. Mais alors comment ça se fait que je route des mails qui ne viennent pas de chez moi, et qui ne vont pas chez moi ? Mon serveur serait configuré en &lt;a href=&quot;https://en.wikipedia.org/wiki/Open_mail_relay&quot;&gt;OpenRelay&lt;/a&gt; (ça serait inquiétant) ?&lt;/p&gt;

&lt;p&gt;Examinons le contenu brut du mail à partir de son ID. La commande postcat permet de le faire pour Postfix, à adapter selon votre MTA.&lt;/p&gt;

&lt;pre&gt;
# postcat -q 1430281C33&lt;/pre&gt;          &lt;p&gt;Ci-dessous la sortie de la commande postcat que j'ai colorisée :&lt;/p&gt;

&lt;pre&gt;
&lt;span style=&quot;color:#696969;&quot;&gt;*** ENVELOPE RECORDS deferred/1/1430281C33 ***&lt;/span&gt;
&lt;span style=&quot;color:#696969;&quot;&gt;message_size:            8589             234               1               0            8589
message_arrival_time: Thu Apr 28 14:51:58 2016
create_time: Thu Apr 28 14:51:58 2016
named_attribute: log_message_origin=local
named_attribute: trace_flags=0
sender:
original_recipient: spammeur@spamserveur.net.ae
recipient: spammeur@spamserveur.net.ae&lt;/span&gt;
&lt;span style=&quot;color:#00FFFF;&quot;&gt;*** MESSAGE CONTENTS deferred/1/1430281C33 ***
Received: by monserveur.com (Postfix)
    id 1430281C33; Thu, 28 Apr 2016 14:51:58 +0200 (CEST)
Date: Thu, 28 Apr 2016 14:51:58 +0200 (CEST)
From: MAILER-DAEMON@monserveur.com (Mail Delivery System)
Subject: Undelivered Mail Returned to Sender
To: spammeur@spamserveur.net.ae
Auto-Submitted: auto-replied
MIME-Version: 1.0&lt;/span&gt;
&lt;span style=&quot;color:#FF0000;&quot;&gt;Content-Type: multipart/report; report-type=delivery-status;
    boundary=&quot;B25FA81C32.1461847918/monserveur.com&quot;&lt;/span&gt;
&lt;span style=&quot;color:#00FFFF;&quot;&gt;Content-Transfer-Encoding: 8bit
Message-Id: &amp;lt;20160428125158.1430281C33@monserveur.com&amp;gt;&lt;/span&gt;

&lt;strong&gt;This is a MIME-encapsulated message.&lt;/strong&gt;

&lt;span style=&quot;color:#FF0000;&quot;&gt;--B25FA81C32.1461847918/monserveur.com&lt;/span&gt;
&lt;span style=&quot;color:#00FFFF;&quot;&gt;Content-Description: Notification
Content-Type: text/plain; charset=us-ascii&lt;/span&gt;

&lt;strong&gt;This is the mail system at host monserveur.com.

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

                   The mail system

&amp;lt;monclient@gmail.com&amp;gt;: host
    gmail-smtp-in.l.google.com[2a00:1450:400c:xxxx::xxxx] said: 552-5.7.0 This
    message was blocked because its content presents a potential 552-5.7.0
    security issue. Please visit 552-5.7.0
    https://support.google.com/mail/answer/6590 to review our message 552 5.7.0
    content and attachment content guidelines. cw9si10769736wjb.20 - gsmtp (in
    reply to end of DATA command)&lt;/strong&gt;

&lt;span style=&quot;color:#FF0000;&quot;&gt;--B25FA81C32.1461847918/monserveur.com&lt;/span&gt;
&lt;span style=&quot;color:#00FFFF;&quot;&gt;Content-Description: Delivery report
Content-Type: message/delivery-status

Reporting-MTA: dns; monserveur.com
X-Postfix-Queue-ID: B25FA81C32
X-Postfix-Sender: rfc822; spammeur@spamserveur.net.ae
Arrival-Date: Thu, 28 Apr 2016 14:51:57 +0200 (CEST)

Final-Recipient: rfc822; monclient@gmail.com
Original-Recipient: rfc822;monclient@gmail.com
Action: failed
Status: 5.7.0
Remote-MTA: dns; gmail-smtp-in.l.google.com
Diagnostic-Code: smtp; 552-5.7.0 This message was blocked because its content
    presents a potential 552-5.7.0 security issue. Please visit 552-5.7.0
    https://support.google.com/mail/answer/6590 to review our message 552 5.7.0
    content and attachment content guidelines. cw9si10769736wjb.20 - gsmtp&lt;/span&gt;

&lt;span style=&quot;color:#FF0000;&quot;&gt;--B25FA81C32.1461847918/monserveur.com&lt;/span&gt;
&lt;span style=&quot;color:#00FFFF;&quot;&gt;Content-Description: Undelivered Message
Content-Type: message/rfc822
Content-Transfer-Encoding: 8bit

Return-Path: &amp;lt;spammeur@spamserveur.net.ae&amp;gt;
Received: from localhost (localhost [127.0.0.1])
    by monserveur.com (Postfix) with ESMTP id B25FA81C32
    for &amp;lt;monclient@gmail.com&amp;gt;; Thu, 28 Apr 2016 14:51:57 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at monserveur.com
Received: from monserveur.com ([127.0.0.1])
    by localhost (monserveur.com [127.0.0.1]) (amavisd-new, port 10024)
    with ESMTP id vn_xZRLJ3EKq for &amp;lt;monclient@gmail.com&amp;gt;;
    Thu, 28 Apr 2016 14:51:51 +0200 (CEST)
Received: by monserveur.com (Postfix, from userid 5000)
    id BE51181C31; Thu, 28 Apr 2016 14:51:51 +0200 (CEST)
X-Sieve: Pigeonhole Sieve 0.4.2
X-Sieve-Redirected-From: contact@monclient.com
Delivered-To: contact@monclient.com
Received: from localhost (localhost [127.0.0.1])
    by monserveur.com (Postfix) with ESMTP id 95E2581C33
    for &amp;lt;contact@monclient.com&amp;gt;; Thu, 28 Apr 2016 14:51:51 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at monserveur.com
Received: from monserveur.com ([127.0.0.1])
    by localhost (monserveur.com [127.0.0.1]) (amavisd-new, port 10024)
    with ESMTP id 8agkFLPzF_vy for &amp;lt;contact@monclient.com&amp;gt;;
    Thu, 28 Apr 2016 14:51:44 +0200 (CEST)
Received: from bba148580.serveurspam.net.ae (bba148580.serveurspam.net.ae [217.165.xxx.xxx])
    by monserveur.com (Postfix) with ESMTP id 774C481C27
    for &amp;lt;contact@monclient.com&amp;gt;; Thu, 28 Apr 2016 14:51:44 +0200 (CEST)
Received: from www.serveurspam.net.ae ([127.0.0.1]) by AMAZONA-F00CA66 with Microsoft SMTPSVC(7.5.7601.17514);
     Thu, 28 Apr 2016 16:51:42 +0400
Date: Thu, 28 Apr 2016 16:51:42 +0400
To: &quot;contact@monclient.com&quot; &amp;lt;contact@monclient.com&amp;gt;
From: xxxx xxxx &amp;lt;spammeur@spamserveur.net.ae&amp;gt;
Subject: [SPAM] FW: Invoice
Message-ID: &amp;lt;be0fa65c2e77bf81d3fd1b0216e8e742@www.serveurspam.net.ae&amp;gt;
X-Priority: 3
X-Mailer: PHPMailer [version 1.73]
MIME-Version: 1.0&lt;/span&gt;
&lt;span style=&quot;color:#FF0000;&quot;&gt;Content-Type: multipart/mixed;
    boundary=&quot;b1_be0fa65c2e77bf81d3fd1b0216e8e742&quot;&lt;/span&gt;
&lt;span style=&quot;color:#00FFFF;&quot;&gt;X-OriginalArrivalTime: 28 Apr 2016 16:51:42.0538 (UTC) FILETIME=[40C0DFC0:01D1A068]&lt;/span&gt;

&lt;span style=&quot;color:#FF0000;&quot;&gt;--b1_be0fa65c2e77bf81d3fd1b0216e8e742&lt;/span&gt;
&lt;span style=&quot;color:#00FFFF;&quot;&gt;Content-Type: multipart/alternative;
    boundary=&quot;b2_be0fa65c2e77bf81d3fd1b0216e8e742&quot;&lt;/span&gt;

&lt;span style=&quot;color:#FF0000;&quot;&gt;--b2_be0fa65c2e77bf81d3fd1b0216e8e742&lt;/span&gt;
&lt;span style=&quot;color:#00FFFF;&quot;&gt;Content-Type: text/plain; charset = &quot;iso-8859-1&quot;
Content-Transfer-Encoding: 8bit&lt;/span&gt;

&lt;strong&gt;Please find attached invoice #726990

Have a nice day

Rowena Pittman
Executive Director Sales Account Management Training Performance Support&lt;/strong&gt;

&lt;span style=&quot;color:#FF0000;&quot;&gt;--b2_be0fa65c2e77bf81d3fd1b0216e8e742&lt;/span&gt;
&lt;span style=&quot;color:#00FFFF;&quot;&gt;Content-Type: text/html; charset = &quot;iso-8859-1&quot;
Content-Transfer-Encoding: 8bit&lt;/span&gt;

&lt;strong&gt;&amp;lt;html&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;p&amp;gt;Please find attached invoice #726990&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Have a nice day&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Rowena Pittman&amp;lt;br&amp;gt;
Executive Director Sales Account Management Training Performance Support&amp;lt;/p&amp;gt;
&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&lt;/strong&gt;

&lt;span style=&quot;color:#FF0000;&quot;&gt;--b2_be0fa65c2e77bf81d3fd1b0216e8e742--
--b1_be0fa65c2e77bf81d3fd1b0216e8e742&lt;/span&gt;
&lt;span style=&quot;color:#00FFFF;&quot;&gt;Content-Type: application/zip; name=&quot;B1095_scan-invoice_0B0C3F.zip&quot;
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=&quot;B1095_scan-invoice_0B0C3F.zip&quot;&lt;/span&gt;

&lt;strong&gt;UEsDBBQAAAAIAIRenEiR5N/wYgcAAHQTAAAKAAAAMTk0MGMwOS5qc9VYaW/TMBj+DBL/IUQC
ElYGLacoCNJr7Wh6LKVrixBKHCdxDid17oz9d+ys45IzBN+YtmWLX7/v4+c93Uwnwgha4xSe

...&lt;/strong&gt;

&lt;span style=&quot;color:#FF0000;&quot;&gt;--b1_be0fa65c2e77bf81d3fd1b0216e8e742--&lt;/span&gt;

&lt;span style=&quot;color:#FF0000;&quot;&gt;--B25FA81C32.1461847918/monserveur.com--&lt;/span&gt;
&lt;span style=&quot;color:#696969;&quot;&gt;*** HEADER EXTRACTED deferred/1/1430281C33 ***
named_attribute: encoding=8bit
*** MESSAGE FILE END deferred/1/1430281C33 ***&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Les lignes que j'ai mises en &lt;span style=&quot;color:#696969;&quot;&gt;gris&lt;/span&gt; ne sont pas très intéressantes : il s'agit de l'enveloppe et des informations fournies par le système qui gère la queue, intéressons-nous plutôt au reste.&lt;/p&gt;

&lt;p&gt;Les lignes en &lt;span style=&quot;color:#0000FF;&quot;&gt;bleu&lt;/span&gt; sont les en-têtes, ce sont elles qui retracent à la fois le format du message, mais aussi leur trajet à travers les différents serveurs mails qui l'ont manipulé. Comme une liste de tampons sur un passeport. Ce sont en particulier les lignes commençant par &lt;span style=&quot;color:#0000FF;&quot;&gt;Received&lt;/span&gt;, qui tracent le trajet des mails à travers les échanges entre les serveurs. La première ligne Received correspondant au dernier échange réalisé, et la dernière ligne &lt;span style=&quot;color:#0000FF;&quot;&gt;Received&lt;/span&gt; au premier échange réalisé.&lt;/p&gt;

&lt;p&gt;Dans l'en-tête on retrouve aussi l'ID du message, &lt;strong&gt;1430281C33&lt;/strong&gt;, et son parcours entre les seveurs mail. Chaque serveur par lequel le mail passe va rajouter une ligne, la première ligne correspondant au dernier serveur ayant reçu le message.&lt;/p&gt;

&lt;p&gt;Les lignes en &lt;span style=&quot;color:#FF0000;&quot;&gt;rouge&lt;/span&gt; sont ce que l'on appelle les boundaries (et leurs déclarations). Ce sont des lignes de séparation permettant de dissocier les pièces jointes du reste du message. Ici on en a plusieurs, parce qu'en fait à chaque échange, le mail s'est fait attacher à un autre mail. Ce n'est pas courant, à moins que le mail n'ai été enrichi d'informations supplémentaire après un &quot;rejet&quot; du serveur de destination. Ici, il s'est donc probablement fait &quot;jeter&quot; plusieurs fois !&lt;/p&gt;

&lt;p&gt;Commençons notre analyse par la fin du message. Le mail original contenait visiblement lui aussi une pièce jointe, et à en juger par le texte invitant à ouvrir la pièce jointe, il est fort possible que ça soit un SCAM. Un message vous invitant à ouvrir un faux fichier PDF qui va infecter l'ordinateur. Heureusement donc que ce mail n'est pas arrivé jusqu'à sa destination.&lt;/p&gt;

&lt;p&gt;Remontons un peu, on constate que le mail a été envoyé avec PHPMailer, et qu'il a été marqué en [SPAM] dans le sujet par mon filtre antispam. La première trace de l'arrivée du mail est la suivante :&lt;/p&gt;

&lt;pre&gt;
&lt;span style=&quot;color:#00FFFF;&quot;&gt;Received: from bba148580.serveurspam.net.ae (bba148580.serveurspam.net.ae [217.165.xxx.xxx]) by monserveur.com (Postfix) with ESMTP id 774C481C27 for &amp;lt;contact@monclient.com&amp;gt;; Thu, 28 Apr 2016 14:51:44 +0200 (CEST)
Received: from www.serveurspam.net.ae ([127.0.0.1]) by AMAZONA-F00CA66 with Microsoft SMTPSVC(7.5.7601.17514); Thu, 28 Apr 2016 16:51:42 +0400&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;La ligne au-dessus, c'est la trace du passage à l'antispam et à l'antivirus :&lt;/p&gt;

&lt;pre&gt;
&lt;span style=&quot;color:#00FFFF;&quot;&gt;Received: from localhost (localhost [127.0.0.1]) by monserveur.com (Postfix) with ESMTP id 95E2581C33 for &amp;lt;contact@monclient.com&amp;gt;; Thu, 28 Apr 2016 14:51:51 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at monserveur.com
Received: from monserveur.com ([127.0.0.1]) by localhost (monserveur.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8agkFLPzF_vy for &amp;lt;contact@monclient.com&amp;gt;; Thu, 28 Apr 2016 14:51:44 +0200 (CEST)&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Rien de spécial, l'antivirus et l'antispam sont installés en local et ont fait leur job dès que le message a été reçu. Continuons.&lt;/p&gt;

&lt;pre&gt;
&lt;span style=&quot;color:#00FFFF;&quot;&gt;X-Sieve: Pigeonhole Sieve 0.4.2
X-Sieve-Redirected-From: contact@monclient.com&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Ça c'est le mécanisme qui gère les alias de mon serveur. &lt;a href=&quot;https://fr.wikipedia.org/wiki/Sieve&quot;&gt;Sieve&lt;/a&gt; va rediriger l'adresse contact@monclient.com vers la bonne adresse de destination, l'adresse contact@monclient.com étant un alias.&lt;/p&gt;

&lt;pre&gt;
&lt;span style=&quot;color:#00FFFF;&quot;&gt;Received: from monserveur.com ([127.0.0.1]) by localhost (monserveur.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vn_xZRLJ3EKq for &amp;lt;monclient@gmail.com&amp;gt;; Thu, 28 Apr 2016 14:51:51 +0200 (CEST)
Received: by monserveur.com (Postfix, from userid 5000) id BE51181C31; Thu, 28 Apr 2016 14:51:51 +0200 (CEST)&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;On transfère tout ça au MTA local pour envoi à la destination finale :&lt;/p&gt;

&lt;pre&gt;
&lt;span style=&quot;color:#00FFFF;&quot;&gt;Received: from localhost (localhost [127.0.0.1]) by monserveur.com (Postfix) with ESMTP id B25FA81C32 for &amp;lt;monclient@gmail.com&amp;gt;; Thu, 28 Apr 2016 14:51:57 +0200 (CEST)&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Fin du premier message, on traverse la boundary pour voir ce qu'il s'est passé ensuite :&lt;/p&gt;

&lt;pre&gt;
&lt;strong&gt;&amp;lt;monclient@gmail.com&amp;gt;: host gmail-smtp-in.l.google.com[2a00:1450:400c:xxxx::xxxx] said: 552-5.7.0 This message was blocked because its content presents a potential 552-5.7.0 security issue.&lt;/strong&gt;&lt;/pre&gt;

&lt;p&gt;Ça c'est moins cool. En gros, gmail a jeté le message, parce que la pièce jointe était sans doute contaminée. Mon antivirus n'a rien vu, il va falloir chercher pourquoi (plus tard).&lt;/p&gt;

&lt;p&gt;On continue de remonter, et au-dessus de la dernière boundary, on a :&lt;/p&gt;

&lt;pre&gt;
&lt;span style=&quot;color:#00FFFF;&quot;&gt;Received: by monserveur.com (Postfix) id 1430281C33; Thu, 28 Apr 2016 14:51:58 +0200 (CEST)&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Ok, gmail m'a renvoyé le message plus ou moins gentiement en m'expliquant qu'il n'en voulait pas, et mon serveur essaie de le transférer au spammeur original qui nous a fermé sa porte. Le mail reste donc en queue jusqu'à son expiration... Voilà pourquoi il traîne dans la queue des mails et qu'il n'a été envoyé ni par moi ni pour moi...&lt;/p&gt;

&lt;h3&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;J'espère que cette courte plongée dans les en-têtes d'un mail vous a permis de vous familiariser avec le &quot;vrai&quot; contenu d'un mail.&lt;/p&gt;

&lt;p&gt;Ici je ne peux plus faire grand chose avec ce mail à part le supprimer de la queue mail, le spammeur ayant certainement déjà été bloqué par son hébergeur ou changé d'adresse IP pour continuer à envoyer sans se faire prendre par les blacklists.&lt;/p&gt;

&lt;p&gt;À bientôt pour un nouvel article. &lt;img src=&quot;/blog/themes/mathedit_material3/smilies/smile.png&quot; alt=&quot;:)&quot; class=&quot;smiley&quot;&gt;&lt;/p&gt;</description>
        
              </item>
          <item>
        <title>Diminuer le taux de rejet des mails sortants pour un fournisseur de boîtes mail</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2016/02/09/Diminuer-le-taux-de-rejet-des-mails-sortants-pour-un-fournisseur-de-bo%C3%AEtes-mail</link>
        <guid isPermaLink="false">urn:md5:de20367e11d0beb125dad9998acb8bf6</guid>
        <pubDate>Tue, 09 Feb 2016 21:06:00 +0100</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Informatique</category>
                          <category>exim</category>
                  <category>mail</category>
                  <category>postfix</category>
                  <category>serveur</category>
                <description>&lt;p&gt;En théorie, tout le monde peut s’improviser fournisseur d’emails, il suffit d’une machine avec les ports ouverts sur Internet et de quelques connaissances pour configurer le serveur mail (Postfix, Exim…)&lt;/p&gt;

&lt;p&gt;En pratique, les fournisseurs de mails subissent la «&amp;nbsp;concurrence déloyale&amp;nbsp;» de leur camarades, car envoyer un mail c’est bien, faire en sorte qu’il soit reçu c’est mieux. Les «&amp;nbsp;concurrents&amp;nbsp;» ce sont les fournisseurs de service comme Hotmail, Gmail, Yahoo, et bien d’autres. Afin de lutter contre le SPAM, ces sociétés sont de plus en plus strictes sur la source des mails qui sont reçus par leurs services.&lt;/p&gt;

&lt;p&gt;Une des conséquences c’est que les petits opérateurs, comme une start-up qui fournit de l’hébergement, un FAI associatif, ou même un particulier qui veut se réapproprier Internet, se font bloquer assez rapidement avec peu de solutions de recours, le support faisant souvent la sourde oreille.&lt;/p&gt;

&lt;p&gt;Dans cet article, je vais donc explorer quelques pistes pour vous permettre d’abord d’éviter de vous retrouver bloqués, et ensuite contourner le blocage le cas échéant.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ce billet est le produit de mes expériences avec l'hébergeur &lt;a href=&quot;http://wellhosted.ch&quot;&gt;wellhosted&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;          &lt;h3&gt;Réputation (et monitoring)&lt;/h3&gt;

&lt;p&gt;Déjà, si vous avez une adresse IP dynamique, oubliez l’envoi de mails. Il est très difficile avec une IP dynamique d’assurer à la fois une réception correcte (même avec un MX pointant sur un DynDNS), et un envoi qui réussisse à tous les coups. D’ailleurs, la plupart des opérateurs proposant des IPs dynamiques bloquent le port 25, rendant l’envoi des mails «&amp;nbsp;entre serveurs&amp;nbsp;» impossible.&lt;/p&gt;

&lt;p&gt;Ensuite, la seconde bonne raison pour avoir une IP fixe, c’est que les contrôlent antispam reposent en grande partie sur la réputation des IPs qui leur envoient des mails. Ce mécanisme s’appelle le &lt;a href=&quot;https://fr.wikipedia.org/wiki/Lutte_anti-spam#RBL&quot;&gt;RBL&lt;/a&gt; pour Realtime Block List. Les serveurs s’abonnent à des listes d'adresses IP connues pour émettre du SPAM, et refusent de recevoir les mails depuis ces IPs. Pas de chance si vous avez hérité d’une IP « qui pue », il vous faudra patiemment demander votre retrait de la liste de blocage au cas par cas.&lt;/p&gt;

&lt;p&gt;Il existe des outils pour tester votre IP sur un grand nombre de RBL&amp;nbsp; : &lt;a href=&quot;http://mxtoolbox.com/blacklists.aspx&quot;&gt;mxtoolbox.com/blacklists.aspx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Vous pouvez également mettre en place une surveillance automatique de votre réputation sur plusieurs blocklists, soit &lt;a href=&quot;https://exchange.nagios.org/directory/Plugins/Email-and-Groupware/check_rbl/details&quot;&gt;avec un simple plugin Nagios&lt;/a&gt;, soit avec un outil comme &lt;a href=&quot;http://www.rblmon.com/&quot;&gt;RBLMon&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;A noter que certaines listes ne permettent pas de faire «&amp;nbsp;retirer&amp;nbsp;» votre IP de la liste. Pas d’inquiétude pour ces listes, personne ne les utilise. Il existe par contre des fournisseurs de service qui ne publient pas leurs listes, et qui ont un processus contraignant pour se faire débloquer (Microsoft par exemple).&lt;/p&gt;

&lt;p&gt;Une fois que votre IP est fixe et qu'elle est propre, l’étape suivante c’est conserver la réputation de votre IP et être irréprochable sur les mails que vous envoyez, mail nous verrons cela dans la suite.&lt;/p&gt;

&lt;h3&gt;IPv6&lt;/h3&gt;

&lt;p&gt;Même si ce n’est pas indispensable, IPv6 est le futur d'Internet, et de nombreux serveurs mails parlent IPv6. En utilisant IPv6, vous aurez aussi l’avantage que beaucoup de RBL ne sont pas prêtes pour IPv6, et donc votre IP ne sera certainement pas bloquée sur ces listes.&lt;/p&gt;

&lt;p&gt;Revers de la médaille : oubliez l’utilisation d’une IPv6 exclusive, certains fournisseurs de mail utilisent encore exclusivement IPv4, il vous faudra donc une configuration réseau supportant les deux adressages pour être certain de pouvoir livrer vos mails.&lt;/p&gt;

&lt;h3&gt;Reverse, PTR, et Hostname&lt;/h3&gt;

&lt;p&gt;Le « &lt;a href=&quot;https://en.wikipedia.org/wiki/Reverse_DNS_lookup&quot;&gt;Reverse&lt;/a&gt; », parfois nommé « PTR », est une résolution DNS inverse. De la même façon qu'une résolution DNS permet de passer d'un nom de domaine à une adresse IP, le DNS inverse permet de passer d'une adresse IP à un nom de domaine. Ce mécanisme existe aussi bien pour IPv4 que pour IPv6.&lt;/p&gt;

&lt;p&gt;Si votre fournisseur de service (la personne chez qui vous louez les IPs ou les serveurs) ne vous permet pas de changer le Reverse, changez de prestataire immédiatement ! L'envoi d'un mail à partir d'une adresse IP sans Reverse est souvent rédhibitoire pour le serveur mail de destination (pas de reverse, pas de livraison).&lt;/p&gt;

&lt;p&gt;De plus, votre Reverse doit être consistant :&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;L'adresse IP doit résoudre vers un domaine, et ce même domaine doit résoudre vers l'adresse IP.&lt;/li&gt;
	&lt;li&gt;Le serveur mail doit également fournir son nom de domaine principal dans le processus de négociation, et ce nom doit résoudre correctement vers son IP. Réglez donc les &lt;strong&gt;/etc/hostname&lt;/strong&gt; ; &lt;strong&gt;/etc/mailname&lt;/strong&gt; et &lt;strong&gt;myhostname&lt;/strong&gt; (pour Postfix) correctement.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Une inconsistance à un quelconque niveau est pire qu'une absence de reverse : le serveur de destination considérera qu'il y a peut-être usurpation de l'IP.&lt;/p&gt;

&lt;p&gt;Encore une fois, n'oubliez pas de régler aussi le reverse IPv6 si vous utilisez IPv6 sur votre serveur.&lt;/p&gt;

&lt;h3&gt;Postmaster, Hostmaster, et RFC&lt;/h3&gt;

&lt;p&gt;Certains serveurs mails sont un peu soupe au lait. Par exemple, il peut arriver que votre réputation descende en flèche juste parce que le propriétaire du serveur n’a pas de moyen automatisé de vous contacter.&lt;/p&gt;

&lt;p&gt;J’explique : dans les &lt;a href=&quot;https://fr.wikipedia.org/wiki/Request_for_comments&quot;&gt;RFC&lt;/a&gt; (Request For Comment, la base des normes et protocoles sur Internet), il est prévu qu’un serveur mail émettant du courrier possède des adresses particulières, à savoir &lt;a href=&quot;mailto:postmaster@ledomaine.com&quot;&gt;postmaster@ledomaine.com&lt;/a&gt; et &lt;a href=&quot;mailto:hostmaster@ledomaine.com&quot;&gt;hostmaster@ledomaine.com&lt;/a&gt; permettant de recevoir les mails envoyés automatiquement par ses pairs.&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;strong&gt;postmaster&lt;/strong&gt; recevra principalement les plaintes pour SPAM, notification de traffic inhabituel sur les mails, et autres requêtes relatives aux mails&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;hostmaster&lt;/strong&gt; recevra les mails relatifs à la gestion du nom de domaine lui-même (demandes de transfert, contact légal du propriétaire - même si on préfère souvent écrire aux contacts du whois), ou parfois pour la réservation d’un certificat SSL (vérification de la propriété du nom de domaine avant délivrance automatique du certificat).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;L’absence d’une adresse postmaster@ valide sur votre serveur vous fait donc paraître pour le serveur mail de destination comme un spammeur qui n’a même pas pris la peine d’implémenter correctement le protocole mail.&lt;/p&gt;

&lt;p&gt;A noter qu’un alias de postmaster@&amp;nbsp;vers une adresse de votre choix fonctionne aussi, même si cette adresse est un trou noir. Mais vous ne devriez pas ignorer les notifications automatiques de blocage et de plaintes envoyées à postmaster…&lt;/p&gt;

&lt;p&gt;De la même façon, préférez un logiciel de serveur mail respectueux des standards (Postfix, Exim) au tout-dernier-serveur-mail-a-la-mode, dont les réponses ne sont peut-être pas entièrement conformes aux RFC.&lt;/p&gt;

&lt;h3&gt;Limites&lt;/h3&gt;

&lt;p&gt;Là on touche au grand dilemme du fournisseur de mails en serveur mutualisé : offrir plus de possibilités aux utilisateurs, ou se protéger contre les usages abusifs ?&lt;/p&gt;

&lt;p&gt;Concrètement, imaginons qu’un de vos utilisateurs décide d’envoyer de la publicité aux 500 adresses mail de sa liste de contacts. Les serveurs recevant un tel volume de messages d’un seul coup ne vont peut-être pas apprécier ce trafic non sollicité et encombrant (de la pub ? du SPAM ? Paf, bloqué).&lt;/p&gt;

&lt;p&gt;Pire : imaginez qu’un de vos utilisateurs se fasse pirater sa boîte mail, et devienne un émetteur de SPAM ou de virus à partir de votre serveur mail ? Vous pensez que les serveurs de destinations seront compréhensifs s’ils reçoivent des centaines de mails par seconde provenant de votre serveur mail ? Ils ne chercheront pas à comprendre : paf, bloqué.&lt;/p&gt;

&lt;p&gt;La solution dans un premier temps c’est de limiter le nombre de mails envoyés par votre serveur, par adresse et par jour. Chaque utilisateur ne devrait par exemple envoyer que 300 mails par jour. Au-delà, le compte sera bloqué en attendant que l’on détermine si c’est une utilisation légitime ou non. La limite est bien entendu à calibrer selon les utilisateurs et les services que vous voulez offrir.&lt;/p&gt;

&lt;p&gt;Il existe plusieurs solutions pour implémenter ce comportement, voici la mienne : &lt;a href=&quot;https://github.com/mpellegrin/ratelimit-policyd&quot;&gt;github.com/mpellegrin/ratelimit-policyd&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;Diminuer la vitesse d’envoi&lt;/h3&gt;

&lt;p&gt;Ça peut paraître un comble au moment où l’on veut recevoir les informations le plus vite possible, et pourtant c’est souvent nécessaire pour l’envoi de mails. Afin d’éviter d’envoyer trop vite un grand volume de mail d’un coup, il peut être nécessaire de mettre en place une limite de mails sortants par seconde et par domaine de destination. Ainsi, le serveur mail de destination ne sera pas inondé sous le poids des mails à traiter, et sera plus coopératif pour les recevoir (en résumé : il ne vous bloquera pas pour usage abusif de sa bande passante).&lt;/p&gt;

&lt;p&gt;La mitigation du taux d’envoi peut être faite au moyen de simples paramètres pour le serveur mail &lt;a href=&quot;http://steam.io/2013/04/01/postfix-rate-limiting/&quot;&gt;steam.io/2013/04/01/postfix-rate-limiting/&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;DKIM et SPF&lt;/h3&gt;

&lt;p&gt;Avoir un enregistrement &lt;a href=&quot;https://fr.wikipedia.org/wiki/Sender_Policy_Framework&quot;&gt;SPF&lt;/a&gt; valide pour le domaine avec lequel vous envoyez vos mails est pratiquement obligatoire : non seulement cela vous permettra de confirmer que le serveur qui envoie vos mails y est bien autorisé, mais cela vous protégera (un peu) contre les usurpations d'adresses mail. Un exemple de SPF serait :&lt;/p&gt;

&lt;pre&gt;
v=spf1 +a +mx -all&lt;/pre&gt;

&lt;p&gt;Si vous voulez un effet positif maximal, préférez un réglage strict (&quot;-all&quot;) au réglage de debug (&quot;?all&quot;), quitte à élargir votre jeu de règles en insérant toutes vos IPs. Par contre, ne mettez pas un TTL trop haut sur les enregistrements SPF, on ne sait jamais.&lt;/p&gt;

&lt;p&gt;Attention également, pour configurer votre domaine, &lt;a href=&quot;https://mxtoolbox.com/problem/spf/spf-record-deprecated&quot;&gt;le champ de type &quot;SPF&quot; est obsolète&lt;/a&gt;, utilisez un champ de type TXT pour vos enregistrements SPF.&lt;/p&gt;

&lt;p&gt;En complément au mécanisme SPF, parce que le SPF n'est pas toujours suffisant pour assurer au serveur de destination que le mail est légitime, vous pouvez mettre en place le &lt;a href=&quot;https://fr.wikipedia.org/wiki/DomainKeys_Identified_Mail&quot;&gt;DKIM&lt;/a&gt; pour tous vos mails sortants. La configuration est plus complexe, mais elle vaut largement le coup pour vous faire sortir de l'ornière d'une réputation trop faible de votre adresse IP dans les premiers mois.&lt;/p&gt;

&lt;p&gt;Le principe du DKIM c'est d'ajouter une signature aux mails, cette signature étant calculée à partir d'une clef privée. La clef publique est quant à elle publiée dans un enregistrement TXT dans le nom de domaine, permettant au serveur recevant le mail de vérifier la validité de la signature, et donc la légitimité du message envoyé à partir du nom de domaine.&lt;/p&gt;

&lt;h3&gt;Smarthosts&lt;/h3&gt;

&lt;p&gt;Si finalement tout ce dont j'ai parlé plus haut n'a pas fonctionné, et que vous vous êtes fait bloquer sur le réseau d'un des grands fournisseurs de boîtes mail (Google, Microsoft, yahoo...), voici votre dernier recours.&lt;/p&gt;

&lt;p&gt;Outre changer d'adresse IP, ce qui pose souvent d'autres problèmes, votre solution c'est d'utiliser un Smarthost. Le Smarthost, c'est tout simplement un serveur mail qui transfère des mails. C'est ce que l'on appelle aussi un relay mail, qui va renvoyer tous vos mails à la place de votre serveur bloqué.&lt;/p&gt;

&lt;p&gt;Dans l'idéal vous devriez avoir plusieurs smarthosts, pour pouvoir répartir la charge de traitement, et les échanger lorsque l'adresse IP de l'un d'eux se fait bloquer. Ainsi vous ne touchez pas à vos MX, et vous avez un réseau permettant de faire sortir des mails indépendemment de votre réseau de réception.&lt;/p&gt;

&lt;p&gt;Le routage vers le Smarthost se règle très simplement dans Postfix, &lt;a href=&quot;http://postfix.traduc.org/index.php/STANDARD_CONFIGURATION_README.html&quot;&gt;en utilisant la directive &lt;strong&gt;transport_maps&lt;/strong&gt; de Postfix&lt;/a&gt; et en configurant un second serveur mail (le smarthost) en mode Relay.&lt;/p&gt;

&lt;p&gt;Attention cependant au moment de créer votre smarthost à ne pas créer de configuration en &quot;Open Relay&quot;, qui permettrait à n'importe qui d'envoyer des mails à travers le smarthost, la sentence sera immédiate lorsque des spammeurs s'en apercevront. Réglez bien votre &lt;strong&gt;mynetwork&lt;/strong&gt;, et &lt;strong&gt;sender_restrictions&lt;/strong&gt; (&lt;a href=&quot;http://www.postfix.org/SMTPD_ACCESS_README.html#global&quot;&gt;par exemple avec Postfix&lt;/a&gt;).&lt;/p&gt;

&lt;h3&gt;Pour aller plus loin&lt;/h3&gt;

&lt;p&gt;Voici une liste d'outils assez pratique lorsque l'on configure ou que l'on cherche la cause d'un problème de délivrance sur un serveur mail :&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;https://www.mail-tester.com/&quot;&gt;Mail Tester&lt;/a&gt; (indispensable pour vérifier votre configuration)&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://mxtoolbox.com&quot;&gt;MXToolbox&lt;/a&gt; (le couteau suisse des tests sur les serveurs mails)&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://support.google.com/mail/answer/81126?hl=fr&quot;&gt;Quelques conseils de Google&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Quelques liens pour (essayer de) se faire retirer de la Blocklist :&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;https://postmaster.live.com/snds/index.aspx&quot;&gt;Pour se faire dé-bannir par Microsoft&lt;/a&gt; (sans garanties...)&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://support.google.com/mail/contact/bulk_send_new?hl=en&amp;amp;rd=1&quot;&gt;Pour se faire dé-bannir par Google&lt;/a&gt; (sans garanties)&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://help.yahoo.com/l/us/yahoo/mail/postmaster/bulkv2.html&quot;&gt;Pour se faire débannir par Yahoo&lt;/a&gt; (sans garanties)&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://postmaster.aol.com/whitelist-request&quot;&gt;Pour se faire débannir par AOL&lt;/a&gt; (sans garanties)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Les programmes de monitoring de réputation :&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;https://postmaster.google.com&quot;&gt;Google Postmaster Tools&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://sendersupport.olc.protection.outlook.com/pm/services.aspx&quot;&gt;Services de Microsoft&lt;/a&gt;, dont :
	&lt;ul&gt;
		&lt;li&gt;&lt;a href=&quot;https://sendersupport.olc.protection.outlook.com/snds/&quot;&gt;Outlook.com Smart Network Data Services (SNDS)&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;https://sendersupport.olc.protection.outlook.com/snds/JMRP.aspx&quot;&gt;Junk Mail Report Program (JMRP)&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://help.yahoo.com/kb/postmaster/sign-manage-yahoo-complaint-feedback-loop-program-sln3438.html?guce_referrer=aHR0cHM6Ly9oZWxwLnlhaG9vLmNvbS9rYi9wb3N0bWFzdGVyLz9ndWNlX3JlZmVycmVyPWFIUjBjSE02THk5M2QzY3VjWGRoYm5RdVkyOXRMdyZndWNlX3JlZmVycmVyX3NpZz1BUUFBQUxFa3d6SjZia2U1LWgtOHExaWtkd3prNmJYUFRtdV81bDZHcVlWbHBjcVVNNm5PNDRlRDZFN0F0TmtjdjlUTmxJSHE0RWlJTC0tbjgteGRyNjVueXEyZUdnQmFrYlFhWjdKa0hLbzg5cFlZdVRoS19waFRfZG9qWFkxaFV0NnlUakhYMW5sZEdhY0J2ZTZwNzFmaUdvdTkxS2U2YkRXLXJBdzhjSjJhT1FiQiZfZ3VjX2NvbnNlbnRfc2tpcD0xNTk3MTg3Mzk3&amp;amp;guce_referrer_sig=AQAAADXcyLkhrnEIWxifEsj79itT56DobcqMVN0QwUcHJzVyohNuP5BfaUg_mtqZ60g_-s7a_L2QHy7IwWqA9NHXmzTnBFSmAGIBh67-9hFpKz63Kb3ojU1XzLWuHWKK1YQiwWZiJogj1Ij6bYWhR2o8cu8--JvB2O9XEoIv8oh2w2US&amp;amp;_guc_consent_skip=1597187419&quot;&gt;Yahoo Complaint Feedback Loop (CFL)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
        
              </item>
          <item>
        <title>Set-up SQL quarantine with Amavisd-new and ISPConfig</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2015/12/05/Set-up-SQL-quarantine-with-Amavisd-new-and-ISPConfig</link>
        <guid isPermaLink="false">urn:md5:c449e2fbaef8eadc5d8276ac89e472d3</guid>
        <pubDate>Sun, 06 Dec 2015 16:56:00 +0100</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>amavis</category>
                  <category>debian</category>
                  <category>ISPConfig</category>
                  <category>jessie</category>
                  <category>mail</category>
                  <category>quarantine</category>
                  <category>server</category>
                  <category>spam</category>
                  <category>sql</category>
                <description>&lt;p&gt;It's documented, but it took me two days to do it correctly, so here is how to reconfigure an ISPConfig installation of Amavis to store quarantined mail in SQL database, in order to install a quarantine viewer like Mailzu.&lt;/p&gt;          &lt;h3&gt;1. Prerequisites&lt;/h3&gt;

&lt;ul&gt;
	&lt;li&gt;A working Postfix+Amavis stack with ISPConfig&lt;/li&gt;
	&lt;li&gt;A working SQL (PostgreSQL, MySQL...) database&lt;/li&gt;
	&lt;li&gt;Optional : a working mail server with PHP (for Mailzu)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Jump to &lt;a href=&quot;https://uname.pingveno.net/blog/index.php/post/2015/12/05/Set-up-SQL-quarantine-with-Amavisd-new-and-ISPConfig#installation&quot;&gt;Installation&lt;/a&gt; if you know what you are doing.&lt;/p&gt;

&lt;h3&gt;2. Off-subject generic explanations&lt;/h3&gt;

&lt;h4&gt;2.1 Amavis and ISPConfig policies&lt;/h4&gt;

&lt;figure style=&quot;float: right; margin: 0 0 1em 1em;&quot;&gt;&lt;a class=&quot;media-link&quot; href=&quot;https://uname.pingveno.net/blog/public/captures/ispconfig/ispconfig_mail_spamfilter_policy_tag_levels.png&quot;&gt;&lt;img alt=&quot;ispconfig_mail_spamfilter_policy_tag_levels.png&quot; class=&quot;media&quot; src=&quot;https://uname.pingveno.net/blog/public/captures/ispconfig/.ispconfig_mail_spamfilter_policy_tag_levels_s.png&quot; /&gt;&lt;/a&gt;

&lt;figcaption&gt;ISPConfig policies, Tag-Levels&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;In a default ISPConfig installation per-user ISPConfig policies are loaded. The configuration file for Amavis, written by ISPConfig contains :&lt;/p&gt;

&lt;pre&gt;
@lookup_sql_dsn =
   ( ['DBI:mysql:database=dbispconfig;host=127.0.0.1;port=3306', 'ispconfig', 'xxxx'] );
$sql_select_policy =
   'SELECT *,spamfilter_users.id'.
   ' FROM spamfilter_users LEFT JOIN spamfilter_policy ON spamfilter_users.policy_id=spamfilter_policy.id'.
   ' WHERE spamfilter_users.email IN (%k) ORDER BY spamfilter_users.priority DESC';
$sql_select_white_black_list = 'SELECT wb FROM spamfilter_wblist'.
    ' WHERE (spamfilter_wblist.rid=?) AND (spamfilter_wblist.email IN (%k))' .
    ' ORDER BY spamfilter_wblist.priority DESC';&lt;/pre&gt;

&lt;p&gt;It means that whatever you would set as&amp;nbsp;&lt;strong&gt;$sa_spam_subject_tag&lt;/strong&gt;, &lt;strong&gt;$sa_tag_level_deflt&lt;/strong&gt;, &lt;strong&gt;$sa_tag2_level_deflt&lt;/strong&gt;, &lt;strong&gt;$sa_kill_level_deflt&lt;/strong&gt;, &lt;strong&gt;$sa_dsn_cutoff_level&lt;/strong&gt;, it will be overridden by per-user policies.&lt;/p&gt;

&lt;p&gt;The ISPConfig policies can be changed in tab Email =&amp;gt; Spamfilter =&amp;gt; Policy in ISPConfig panel. If you struggle wondering why your message keeps getting smashed at level 4.5, look at the sa_tag_level in policies. We will have to change values in that policies, to make the SQL quarantine working.&lt;/p&gt;

&lt;h4&gt;2.2 Lookup DSN and Storage DSN&lt;/h4&gt;

&lt;p&gt;DSN (Data Source Name) are the connection strings with host, username, and password, used to connect to databases.&lt;/p&gt;

&lt;p&gt;Amavis can set two DSN : one for Policies lookup (used to retrieve ISPConfig policies from Panel), and one for storage of mail meta informations and quarantine. We will use the Storage DSN to set up a secondary database for quarantine storage, to not mess with existing ISPConfig database.&lt;/p&gt;

&lt;h4&gt;2.3 Levels and cutoffs&lt;/h4&gt;

&lt;p&gt;Amavis uses Spamassassin to score the mail, in order to decide what to do with it. The category of test (spam test, antivirus, etc) and the score along with levels determines the actions Amavis will trigger, and the final destiny where the mail belongs.&lt;/p&gt;

&lt;p&gt;Spamassassin levels are :&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;strong&gt;tag_level&lt;/strong&gt; : a message above that score will be tagged with &lt;strong&gt;X-Spam-Status&lt;/strong&gt;, &lt;strong&gt;X-Spam-Score&lt;/strong&gt; and &lt;strong&gt;X-Spam-Level&lt;/strong&gt; headers.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;tag2_level&lt;/strong&gt; : a message above that score will be marked &lt;strong&gt;as X-Spam-Status: Yes&lt;/strong&gt; and the subject is changed if &lt;strong&gt;sa_spam_modifies_subj&lt;/strong&gt; is set to true.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;kill_level&lt;/strong&gt; : a message above that score is taken to the &lt;strong&gt;final_spam_destiny&lt;/strong&gt;, and quarantined, it will not be delivered unless &lt;strong&gt;D_PASS&lt;/strong&gt; is set to &lt;strong&gt;final_spam_destiny&lt;/strong&gt;.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;dsn_cutoff_level&lt;/strong&gt; : a message above that level will never trigger a bounce or a reject, whatever &lt;strong&gt;spam_destiny&lt;/strong&gt; is.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;quarantine_cutoff_level&lt;/strong&gt; : a message above that level will not be quarantined.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;2.4 Final &lt;span class=&quot;gt-baf-back&quot;&gt;destinations&lt;/span&gt;&lt;/h4&gt;

&lt;p&gt;Once the message is categorized by Amavis tests (through SpamAssassin, ClamAV, etc), Amavis decides if it should be delivered to user mailbox or not, and if a bounce will be issued.&lt;/p&gt;

&lt;p&gt;This is the purpose of &lt;strong&gt;$final_virus_destiny&lt;/strong&gt;, &lt;strong&gt;$final_spam_destiny&lt;/strong&gt;, &lt;strong&gt;$final_banned_destiny&lt;/strong&gt;, &lt;strong&gt;$final_bad_header_destiny&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;They can take the following values :&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;strong&gt;D_PASS&lt;/strong&gt; : mail will be delivered to inbox.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;D_BOUNCE&lt;/strong&gt; : mail will not be delivered, and a &lt;em&gt;delivery status notification&lt;/em&gt; will be returned by Postifx to sender (except if the score exceeds the &lt;strong&gt;dsn_cutoff&lt;/strong&gt; level)&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;D_REJECT&lt;/strong&gt; : Postfix will answer REJECT to the distant mail server, and the distant mail server may produce a &lt;em&gt;delivery status notification&lt;/em&gt; to the user&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;D_DISCARD&lt;/strong&gt; : forgive and forget : the mail will not be delivered and the sender is not informed. The mail may be quarantined if the &lt;strong&gt;quarantine_cutoff&lt;/strong&gt; level is not exceeded.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;&lt;a name=&quot;installation&quot;&gt;3. Installation&lt;/a&gt;&lt;/h3&gt;

&lt;ul&gt;
	&lt;li&gt;For Amavis : Nothing ! Amavis comes out-of-the-box with SQL storage.&lt;/li&gt;
	&lt;li&gt;For Mailzu : see &lt;a href=&quot;https://uname.pingveno.net/blog/index.php/post/2015/12/05/Set-up-SQL-quarantine-with-Amavisd-new-and-ISPConfig#mailzu&quot;&gt;Mailzu&lt;/a&gt; section.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;4. Configuration&lt;/h3&gt;

&lt;h4&gt;4.1 Database&lt;/h4&gt;

&lt;p&gt;Create an user and a database for quarantine storage :&lt;/p&gt;

&lt;pre&gt;
# mysql -u root -p
mysql&amp;gt; CREATE DATABASE amavis_storage;
mysql&amp;gt; CREATE USER 'amavis_storage'@'localhost' IDENTIFIED BY 'xxxx';
mysql&amp;gt; GRANT ALL PRIVILEGES ON amavis_storage.* TO 'amavis_storage'@'localhost';
mysql&amp;gt; FLUSH PRIVILEGES;&lt;/pre&gt;

&lt;p&gt;Load the initial schema from Amavis docs (usually located in &lt;strong&gt;/usr/share/doc/amavisd-new&lt;/strong&gt;/ ).&lt;/p&gt;

&lt;p&gt;Delete unnecessary tables, as we will be using this database only for mail storage and not for lookups :&lt;/p&gt;

&lt;pre&gt;
# mysql -u amavis_storage -p amavis_storage
mysql&amp;gt; DROP TABLE users;
mysql&amp;gt; DROP TABLE mailaddr;
mysql&amp;gt; DROP TABLE policy;
mysql&amp;gt; DROP TABLE wblist;
&lt;/pre&gt;

&lt;p&gt;Nota Bene : while executing &lt;strong&gt;DROP TABLE users&lt;/strong&gt;, don't be silly, and do not remove mysql users database.&lt;/p&gt;

&lt;h4&gt;4.2 Amavis&lt;/h4&gt;

&lt;p&gt;Update your Amavis configuration &lt;strong&gt;/etc/amavis/conf.d/50_user&lt;/strong&gt; :&lt;/p&gt;

&lt;pre&gt;
@storage_sql_dsn = ( ['DBI:mysql:database=amavis_storage;host=127.0.0.1;port=3306', 'amavis_storage', 'xxxx'] );  # none, same, or separate database

# Quarantine SPAM into SQL server.
$spam_quarantine_to = 'spam-quarantine';
$spam_quarantine_method = 'sql:';

# Quarantine VIRUS into SQL server.
$virus_quarantine_to = 'virus-quarantine';
$virus_quarantine_method = 'sql:';

# Quarantine BANNED message into SQL server.
$banned_quarantine_to = 'banned-quarantine';
$banned_files_quarantine_method = 'sql:';

# Quarantine Bad Header message into SQL server.
$bad_header_quarantine_method = 'sql:';
$bad_header_quarantine_to = 'badheader-quarantine';

# Do not store non-quarantined messages info
# You can set it to 1 (the default) to test if Amavis is filling correctly the tables maddr, msgs, and msgcrpt
$sql_store_info_for_all_msgs = 0;

#
# SQL Select statements
#

$sql_select_policy =
   'SELECT *,spamfilter_users.id'.
   ' FROM spamfilter_users LEFT JOIN spamfilter_policy ON spamfilter_users.policy_id=spamfilter_policy.id'.
   ' WHERE spamfilter_users.email IN (%k) ORDER BY spamfilter_users.priority DESC';

$sql_select_white_black_list = 'SELECT wb FROM spamfilter_wblist'.
    ' WHERE (spamfilter_wblist.rid=?) AND (spamfilter_wblist.email IN (%k))' .
    ' ORDER BY spamfilter_wblist.priority DESC';

#
# Quarantine settings
#

$final_virus_destiny = D_BOUNCE;
$final_spam_destiny = D_DISCARD;
$final_banned_destiny = D_BOUNCE;
$final_bad_header_destiny = D_PASS;

# Default settings, we st this very high to not filter aut emails accidently
$sa_spam_subject_tag = '[SPAM] ';
$sa_tag_level_deflt  = 20.0;  # add spam info headers if at, or above that level
$sa_tag2_level_deflt = 60.0; # add 'spam detected' headers at that level
$sa_kill_level_deflt = 60.0; # triggers spam evasive actions
$sa_dsn_cutoff_level = 100;   # spam level beyond which a DSN is not sent
#$sa_debug = 1;

#
# Disable spam and virus notifications for the admin user.
# Can be overridden by the policies in mysql
#

$virus_admin = undef;
$spam_admin = undef;

#
# Enable Logging
#

$DO_SYSLOG = 1;
$LOGFILE = &quot;/var/log/amavis.log&quot;;  # (defaults to empty, no log)

# Set the log_level to 5 for debugging
$log_level = 0;                # (defaults to 0)&lt;/pre&gt;

&lt;h4&gt;4.3 ISPConfig policies&lt;/h4&gt;

&lt;p&gt;Remember that ISPconfig policies are overriding a lot of our configuration in &lt;strong&gt;50_user&lt;/strong&gt;. In order to majke the quarantine work, you have to reconfigure all the available policies in ISPConfig Panel.&lt;/p&gt;

&lt;p&gt;Look at your policies list, you have to change the quarantine settings for every policies :&lt;/p&gt;

&lt;figure style=&quot;{figureStyle}&quot;&gt;&lt;a class=&quot;media-link&quot; href=&quot;https://uname.pingveno.net/blog/public/captures/ispconfig/ispconfig_mail_spamfilter_policy.png&quot;&gt;&lt;img alt=&quot;ispconfig_mail_spamfilter_policy.png&quot; class=&quot;media&quot; src=&quot;https://uname.pingveno.net/blog/public/captures/ispconfig/ispconfig_mail_spamfilter_policy.png&quot; /&gt;&lt;/a&gt;

&lt;figcaption&gt;ISPConfig Mail Spamfilter Policy&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h4&gt;When editing a policy, on the Quarantine tab, set the destinations :&lt;/h4&gt;

&lt;figure style=&quot;{figureStyle}&quot;&gt;&lt;a class=&quot;media-link&quot; href=&quot;https://uname.pingveno.net/blog/public/captures/ispconfig/ispconfig_mail_spamfilter_policy_quarantine.png&quot;&gt;&lt;img alt=&quot;ispconfig_mail_spamfilter_policy_quarantine.png&quot; class=&quot;media&quot; src=&quot;https://uname.pingveno.net/blog/public/captures/ispconfig/ispconfig_mail_spamfilter_policy_quarantine.png&quot; /&gt;&lt;/a&gt;

&lt;figcaption&gt;ISPConfig Mail Spamfilter Policy Quarantine destinations&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;&lt;strong&gt;If you do not fill something in these fields, Amavis will not store quarantined mails in SQL database, and will just discard it !&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These fields correspond to the &lt;strong&gt;virus_quarantine_to&lt;/strong&gt;, &lt;strong&gt;spam_quarantine_to&lt;/strong&gt;, &lt;strong&gt;banned_quarantine_to&lt;/strong&gt;, &lt;strong&gt;bad_header_quarantine_to&lt;/strong&gt; variables in Amavis configuration, and an empty value is overriding those we set in Amavis configuration.&lt;/p&gt;

&lt;h4&gt;4.4 Test&lt;/h4&gt;

&lt;p&gt;Send some spam to your server, check if the tables are populated :&lt;/p&gt;

&lt;pre&gt;
mysql&amp;gt; SELECT * FROM maddr;&lt;/pre&gt;

&lt;p&gt;Check if meta informations are populated :&lt;/p&gt;

&lt;pre&gt;
mysql&amp;gt; SELECT * FROM msgs;
mysql&amp;gt; SELECT * FROM msgrcpt;&lt;/pre&gt;

&lt;p&gt;And if quarantine is filling :&lt;/p&gt;

&lt;pre&gt;
mysql&amp;gt; SELECT * FROM quarantine;&lt;/pre&gt;

&lt;h3&gt;5. Cleanup !&lt;/h3&gt;

&lt;p&gt;You should not &quot;setup and forget&quot; your quarantine SQL storage. Messages has to be deleted periodically, otherwise your database will grow forever. Look at the documentaion in &lt;strong&gt;/usr/share/docs/amavisd-new&lt;/strong&gt; to make a cronjob like this :&lt;/p&gt;

&lt;pre&gt;
#!/bin/bash

SQL_HOST=&quot;localhost&quot;;
SQL_LOGIN=&quot;amavis_storage&quot;
SQL_PASSWORD=&quot;xxxx&quot;
SQL_DB=&quot;amavis_storage&quot;

mysql --user=&quot;$SQL_LOGIN&quot; --password=&quot;$SQL_PASSWORD&quot; --host=&quot;$SQL_HOST&quot; $SQL_DB -e &quot; \
  DELETE FROM msgs WHERE time_num &amp;lt; UNIX_TIMESTAMP() - 30*24*3600; \
  DELETE FROM msgrcpt WHERE NOT EXISTS (SELECT 1 FROM msgs WHERE mail_id=msgrcpt.mail_id); \
  DELETE FROM quarantine WHERE NOT EXISTS (SELECT 1 FROM msgs WHERE mail_id=quarantine.mail_id); \
  DELETE FROM maddr WHERE NOT EXISTS (SELECT 1 FROM msgs WHERE sid=id) AND NOT EXISTS (SELECT 1 FROM msgrcpt WHERE rid=id); \
&quot;
&lt;/pre&gt;

&lt;h3&gt;&lt;a name=&quot;mailzu&quot;&gt;6. Mailzu&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;I have to admit, Mailzu seems a bit obsolete as I had to patch to make it working with Amavis 3.3 tables. But it still works pretty well for a simple task like reading and releasing quarantine mails.&lt;/p&gt;

&lt;h4&gt;6.1 Installation&lt;/h4&gt;

&lt;p&gt;Download the source files at &lt;a href=&quot;http://sourceforge.net/projects/mailzu/&quot;&gt;http://sourceforge.net/projects/mailzu/&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;62. Patch&lt;/h4&gt;

&lt;p&gt;The existing Mailzu source code is quite old, and the schema of Amavis SQL tables changed. Download and apply &lt;a href=&quot;http://sourceforge.net/p/mailzu/patches/10/&quot;&gt;this patch&lt;/a&gt; in to make Mailzu work.&lt;/p&gt;

&lt;h4&gt;6.3 Configuration&lt;/h4&gt;

&lt;p&gt;I suppose that you know how to spawn PHP with CGI to serve the Mailzu files.&lt;/p&gt;

&lt;p&gt;Configure your database login and password in &lt;strong&gt;config/config.php&lt;/strong&gt; :&lt;/p&gt;

&lt;pre&gt;
$conf['db']['dbType'] = 'mysql';
$conf['db']['dbUser'] = 'amavis_storage';
$conf['db']['dbPass'] = 'xxxx';
$conf['db']['dbName'] = 'amavis_storage';
$conf['db']['hostSpec'] = 'localhost:3306';&lt;/pre&gt;

&lt;p&gt;I am using IMAP login to authenticate in Mailzu. Unfortunately, I had to turn off SSL authentication, as it wasn't working. Here is my configuration :&lt;/p&gt;

&lt;pre&gt;
$conf['auth']['serverType'] = 'imap';
$conf['auth']['imap_hosts'] = array( 'localhost:143' );
$conf['auth']['imap_type'] = 'imaptls';
$conf['auth']['imap_domain_name'] = 'example.com';&lt;/pre&gt;

&lt;p&gt;Don't forget to set yourself &quot;super&quot; :&lt;/p&gt;

&lt;pre&gt;
$conf['auth']['s_admins'] = array ('me@example.com');&lt;/pre&gt;

&lt;p&gt;And to set your web uri :&lt;/p&gt;

&lt;pre&gt;
$conf['app']['weburi'] = 'https://example.com/mailzu';&lt;/pre&gt;

&lt;h4&gt;6.4 Configure in-app release&lt;/h4&gt;

&lt;p&gt;Mailzu can also release quarantined mail. I did not implement this function, but you have to set up the amavisd-release internface on an inet socket on port 9998, instead of the existing unix socket located at &lt;strong&gt;/var/lib/amavis/amavisd.sock&lt;/strong&gt; . &lt;a href=&quot;https://www.ijs.si/software/amavisd/amavisd-new-docs.html#quar-release&quot;&gt;Read more&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;References&lt;/h3&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;http://www.iredmail.org/docs/amavisd.sql.db.html&quot;&gt;Explanation of Amavisd SQL database&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://blog.bravi.org/?p=683&quot;&gt;AMaViS: deal with SPAM, Viruses, Banned attachments, and Bad headers&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://www.ijs.si/software/amavisd/amavisd-new-docs.html#quarantine&quot;&gt;amavisd-new documentation bits and pieces&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://www.raygibson.net/kb/amavis/amavisd.conf&quot;&gt;amavis.conf&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://sourceforge.net/projects/mailzu/&quot;&gt;Mailzu&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://sourceforge.net/p/mailzu/patches/10/&quot;&gt;Mailzu patch for Amavis 2.7.0&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
        
          <enclosure url="/blog/public/code/sql/amavis_storage_partial_schema.sql" length="4518" type="application/octet-stream" />
        
              </item>
          <item>
        <title>STOP aux adresses gmail, yahoo, hotmail dans les communications professionnelles</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2015/09/30/STOP-aux-adresses-gmail%2C-yahoo%2C-hotmail-dans-les-communications-professionnelles</link>
        <guid isPermaLink="false">urn:md5:15be7e8893c7a491c07fe1201431880c</guid>
        <pubDate>Wed, 30 Sep 2015 10:49:00 +0200</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>What about Web</category>
                          <category>gouvernement</category>
                  <category>mail</category>
                  <category>mailchimp</category>
                  <category>service civique</category>
                <description>          &lt;p&gt;Ceci est juste un billet d&amp;#8217;humeur sur quelque chose que je trouve de plus en plus exaspérant&amp;#160;: la recrudescence des aderses Gmail, Yahoo, ou Microsoft dans des emails soit-disant sérieux, professionnels, etc.&lt;/p&gt;&lt;p&gt;PME, syndicats, gouvernements, fédérations politiques, arrêtez d&amp;#8217;utiliser des fournisseurs d&amp;#8217;emails grand public, et assumez votre marque&amp;#160;! Vous ne voudriez pas avoir &lt;strong&gt;la publicité de votre imprimeur au verso de tous vos tracts&lt;/strong&gt;&amp;#160;? Alors ne faites pas pareil avec les mails.&lt;/p&gt;&lt;p&gt;Donc &lt;strong&gt;NON&lt;/strong&gt;, ce n&amp;#8217;est pas acceptable, à part si vous êtes un particulier, d&amp;#8217;avoir une adresse mail en @gmail.com, @yahoo.com ou @outlook.com. En faisant cela vous démontrez&amp;#160;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Votre méconnaissance et/ou votre amateurisme le plus total dans l&amp;#8217;utilisation des NTIC.&lt;/li&gt;&lt;li&gt;Qu&amp;#8217;aucun de vos amis, agences de com, ou conseillers n&amp;#8217;a de connaissances solides sur le sujet (ça fait flipper hein&amp;#160;?).&lt;/li&gt;&lt;li&gt;Que vous aimez tellement les américains que vous êtes prêt à leur transmettre tous vos emails.&lt;/li&gt;&lt;li&gt;Que vous êtes radin au point de ne pas dépenser les 30 euros nécessaires pour obtenir un nom de domaine et une boîte mail chez un registrar.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Avoir une adresse contact@monentreprise.com c&amp;#8217;est compliqué&amp;#160;? Non, ça prend &lt;a href=&quot;https://www.gandi.net&quot;&gt;&lt;strong&gt;20 minutes maximum&lt;/strong&gt;&lt;/a&gt; pour peu que vous sachiez comment s&amp;#8217;appelle votre entreprise.&lt;/p&gt;&lt;p&gt;En bonus, le mail que j&amp;#8217;ai reçu ce matin&amp;#160;:&lt;/p&gt;&lt;figure style=&quot;margin: 0 auto; display: block;&quot;&gt;&lt;a class=&quot;media-link&quot; href=&quot;https://uname.pingveno.net/blog/public/posts_thumb/wtf-service-civique.png&quot;&gt;&lt;img class=&quot;media&quot; alt=&quot;wtf-service-civique.png&quot; src=&quot;https://uname.pingveno.net/blog/public/posts_thumb/.wtf-service-civique_m.png&quot; /&gt;&lt;/a&gt;&lt;/figure&gt;&lt;p&gt;Bordel de merde.&lt;/p&gt;</description>
        
              </item>
          <item>
        <title>Postfix : configure postmaster, hostmaster, and abuse catchall  for RFC compliance</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2015/08/29/Postfix-%3A-configure-postmaster%2C-hostmaster%2C-and-abuse-catchall-for-RFC-compliance</link>
        <guid isPermaLink="false">urn:md5:2236b92a9adc8066108e9709c6c32959</guid>
        <pubDate>Sat, 29 Aug 2015 18:02:00 +0200</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>catchall</category>
                  <category>debian</category>
                  <category>mail</category>
                  <category>postfix</category>
                  <category>server</category>
                <description>          &lt;p&gt;This short howto will show you how to set up a catchall for common required email addresses. Some mail servers are testing if mail is accepted on this addresses to detect spammymail servers. Hostmaster address can also be used for domain Trading, to check the ownership of the domain.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;1. &lt;/strong&gt;Create a file named &lt;strong&gt;/etc/postfix/regexp-catchall.cf&lt;/strong&gt; with the following content:&lt;/p&gt;&lt;pre&gt;# Catchall to comply with RFC standards
/^postmaster@/    youshouldreadit@mydomain.com
/^hostmaster@/    youshouldreadit@mydomain.com
/^abuse@/         youshouldreadit@mydomain.com&lt;/pre&gt;&lt;p&gt;Replace &lt;em&gt;youshouldreadit@mydomain.com&lt;/em&gt; with a mail address you actually read.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt; Open &lt;strong&gt;/etc/postfix/main.cf&lt;/strong&gt; and locate (or create) the line &lt;strong&gt;virtual_alias_maps&lt;/strong&gt;, and add at the end &lt;strong&gt;regexp:/etc/postfix/regexp-catchall.cf&lt;/strong&gt;, for instance:&lt;/p&gt;&lt;pre&gt;virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf, regexp:/etc/postfix/regexp-catchall.cf&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;3. &lt;/strong&gt;Restart Postfix.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Warning&amp;#160;: read &lt;a href=&quot;http://uname.pingveno.net/blog/index.php/post/2015/08/29/Postfix-%3A-configure-postmaster%2C-hostmaster%2C-and-abuse-catchall-for-RFC-compliance#c73895&quot;&gt;comment #4&lt;/a&gt; for issues with this setup&lt;/strong&gt;.&lt;/p&gt;</description>
        
              </item>
          <item>
        <title>Configure sender rate limits to prevent spam, using cluebringer (policyd) with Postfix</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2015/03/11/Configure-sender-rate-limits-to-prevent-spam%2C-using-cluebringer-%28policyd%29-with-Postfix</link>
        <guid isPermaLink="false">urn:md5:11c6569b7382d3cd707a41e60deae65c</guid>
        <pubDate>Fri, 13 Mar 2015 09:18:00 +0100</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>cluebringer</category>
                  <category>debian</category>
                  <category>mail</category>
                  <category>policyd</category>
                  <category>postfix</category>
                  <category>server</category>
                <description>&lt;p&gt;This small how-to will show you how to configure cluebringer (aka policyd) to set a per-hour/per-user limit for sent mails. Note that sending to multiple recipient will count like multiple mails were sent.&lt;/p&gt;

&lt;p&gt;This how-to is Debian-oriented but should apply to any unix operating system.&lt;/p&gt;          &lt;h3&gt;Requirements&lt;/h3&gt;

&lt;p&gt;A mail server with Postfix installed.&lt;/p&gt;

&lt;h3&gt;Installation&lt;/h3&gt;

&lt;p&gt;Install a DBMS (MySQL for instance), cluebringer, and cluebringer-webui&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
apt-get install mysql-server cluebringer cluebringer-mysql cluebringer-webui&lt;/pre&gt;

&lt;p&gt;Note that cluebringer-webui will install apache as a dependency if you don&amp;#8217;t already have a webserver.&lt;/p&gt;

&lt;h3&gt;Set-up the Cluebringer database&lt;/h3&gt;

&lt;p&gt;Get the initial database schema that correspond to your DBMS, for instance mysql&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
cp /usr/share/doc/postfix-cluebringer/database/policyd-db.mysql.gz ~/ &amp;amp;&amp;amp; gunzip ~/policyd-db.mysql.gz&lt;/pre&gt;

&lt;p&gt;Create the database, and populate it with the initial dump&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
# cd  ~/ &amp;amp;&amp;amp; mysql -u root -p
mysql&amp;gt; CREATE DATABASE cluebringer;
mysql&amp;gt; CREATE USER 'cluebringer'@'localhost' IDENTIFIED BY 'mypassword';
mysql&amp;gt; GRANT ALL PRIVILEGES ON cluebringer.* TO 'cluebringer'@'localhost';
mysql&amp;gt; \. policyd-db.mysql
mysql&amp;gt; quit
mysql&amp;gt; Bye
&lt;/pre&gt;

&lt;p&gt;Note that on Debian I had to modify the dump to make it work, &lt;em&gt;TYPE=InnoDB&lt;/em&gt; was rejected by MySQL as an invalid syntax.&lt;/p&gt;

&lt;h3&gt;Configure Cluebringer&lt;/h3&gt;

&lt;p&gt;Add your DBMS credentials to the file &lt;strong&gt;/etc/cluebringer/cluebringer.conf&lt;/strong&gt;&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
DSN=DBI:mysql:dbname=cluebringer;host=localhost

DB_Type=mysql
DB_Host=localhost
DB_Port=3306
DB_Name=cluebringer
Username=cluebringer
Password=mypassword&lt;/pre&gt;

&lt;p&gt;And start it&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
service postfix-cluebringer start&lt;/pre&gt;

&lt;h3&gt;Configure Cluebringer webui&lt;/h3&gt;

&lt;p&gt;Configure the file &lt;strong&gt;/etc/cluebringer/cluebringer-webui.conf&lt;/strong&gt; with your DBMS credentials&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
&amp;lt;?php

$DB_DSN=&quot;mysql:host=localhost;dbname=cluebringer&quot;;
$DB_USER=&quot;cluebringer&quot;;
$DB_PASS=&quot;mypassword&quot;;&lt;/pre&gt;

&lt;p&gt;Cluebringer Webui needs a web server to run. Copy the sample configuration from the package documentation&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
cp /usr/share/doc/postfix-cluebringer-webui/examples/httpd/cluebringer-httpd.conf /etc/apache2/conf.d/&lt;/pre&gt;

&lt;p&gt;Restart Apache&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
service apache2 restart&lt;/pre&gt;

&lt;p&gt;You may need to adjust a few things to access it from the outside. If you a really lazy, just make a ssh tunnel to access the webserver from localhost&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
ssh -L 8008:localhost:80 mylogin@mymailserver&lt;/pre&gt;

&lt;p&gt;Don&amp;#8217;t forget&amp;#160;: you have to make this tunnel from the outside, do not run this command on server, it won&amp;#8217;t work.&lt;/p&gt;

&lt;p&gt;You should now be able to open http://localhost:8080/ and see your fresh new Cluebinger Webui&amp;#160;!&lt;/p&gt;

&lt;h3&gt;Configure Cluebringer using its webui&lt;/h3&gt;

&lt;h4&gt;Add a policy&lt;/h4&gt;

&lt;p&gt;Under &lt;strong&gt;Policies&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Main&lt;/strong&gt;, disable Test policy (select policy and choose &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Change&lt;/strong&gt; and switch &lt;strong&gt;Disabled&lt;/strong&gt; to &lt;strong&gt;yes&lt;/strong&gt;, validate)&lt;/p&gt;

&lt;p&gt;Add a new policy&amp;#160;: &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Add&lt;/strong&gt;, give it a name and a description&lt;/p&gt;

&lt;p&gt;Activate your new policy&amp;#160;: select policy and choose &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Change&lt;/strong&gt; (switch &lt;strong&gt;Disabled&lt;/strong&gt; to &lt;strong&gt;no&lt;/strong&gt;)&lt;/p&gt;

&lt;p&gt;Add a new member to your policy&amp;#160;: select it and choose &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Members&lt;/strong&gt;, and then &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Add&lt;/strong&gt;. Specify &lt;strong&gt;any&lt;/strong&gt; as source and &lt;strong&gt;any&lt;/strong&gt; as destination.&lt;/p&gt;

&lt;p&gt;Go back to your policy, choose &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Members&lt;/strong&gt;, and the select your member, do &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Change&lt;/strong&gt;, and activate your new member (switch &lt;strong&gt;Disabled&lt;/strong&gt; to &lt;strong&gt;no&lt;/strong&gt;).&lt;/p&gt;

&lt;h4&gt;Add a quota&lt;/h4&gt;

&lt;p&gt;Under &lt;strong&gt;Quotas&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Configure&lt;/strong&gt;, disable Test quotas.&lt;/p&gt;

&lt;p&gt;Add a new quota&amp;#160;: Choose &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Add&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Name&amp;#160;: whatever you want&lt;/li&gt;
	&lt;li&gt;Track&amp;#160;: &lt;strong&gt;user@domain&lt;/strong&gt;&lt;/li&gt;
	&lt;li&gt;Period (seconds)&amp;#160;: &lt;strong&gt;3600&lt;/strong&gt;&lt;/li&gt;
	&lt;li&gt;Link to policy&amp;#160;: specify the policy you created here&lt;/li&gt;
	&lt;li&gt;Verdict&amp;#160;: &lt;strong&gt;Defer&lt;/strong&gt;&lt;/li&gt;
	&lt;li&gt;Data&amp;#160;: set a custom error message here&lt;/li&gt;
	&lt;li&gt;Comment&amp;#160;: whatever you want&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Activate your quota&amp;#160;: switch &lt;strong&gt;Disabled&lt;/strong&gt; to &lt;strong&gt;no&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Add a limit to your quota&amp;#160;: select your quota, and choose &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Limits&lt;/strong&gt;, then &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Add&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Type&amp;#160;: &lt;strong&gt;MessageCount&lt;/strong&gt;&lt;/li&gt;
	&lt;li&gt;Counter Limit&amp;#160;: &lt;strong&gt;200&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Activate your limit&amp;#160;: switch &lt;strong&gt;Disabled&lt;/strong&gt; to &lt;strong&gt;no&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;Configure Postfix to call Cluebringer for each mail sent&lt;/h3&gt;

&lt;p&gt;Open &lt;strong&gt;/etc/postfix/main.cf&lt;/strong&gt; and locate the line &lt;strong&gt;smtpd_sender_restrictions&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Add &lt;strong&gt;check_policy_service inet:127.0.0.1:10031&lt;/strong&gt; at the end of the line, for instance&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
smtpd_sender_restrictions = check_sender_access mysql:/etc/postfix/mysql-virtual_sender.cf&lt;strong&gt;, check_policy_service inet:127.0.0.1:10031&lt;/strong&gt;&lt;/pre&gt;

&lt;p&gt;If the line does not exists, simply add it.&lt;/p&gt;

&lt;p&gt;Don&amp;#8217;t forget to restart Postfix&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
service postfix restart&lt;/pre&gt;

&lt;h3&gt;Check your config&lt;/h3&gt;

&lt;p&gt;You can now send some mails to see what happens. To check if these mails are passed to Cluebringer, connect to MySQL as the cluebringer user&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
# mysql -u cluebringer -p cluebringer&lt;/pre&gt;

&lt;p&gt;And execute the query&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
mysql&amp;gt; SELECT * FROM quotas_tracking;&lt;/pre&gt;

&lt;p&gt;You should see the value LastUpdate and Counter updating when sending a mail. Note that sending to multiple recipient will count like multiple mails were sent.&lt;/p&gt;

&lt;h3&gt;Pitfalls, bleeding edges, etc&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Cluebringer versions prior to 2.1.x does not support IPv6&lt;/strong&gt;, your customers won&amp;#8217;t be able to send any mail if they have an IPv6 connection.&lt;/p&gt;

&lt;p&gt;Unfortunately, the Debian stable version (wheezy) provides Cluebringer 2.0.10 within its repositories, as well as the experimental release of Debian (sid). As an alternative, you should consider &lt;a href=&quot;http://wiki.policyd.org/download&quot;&gt;installing the 2.1.x experimental Cluebringer&lt;/a&gt; from official website instead of Debian packages from repositories.&lt;/p&gt;

&lt;h3&gt;References&lt;/h3&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;http://wiki.policyd.org/installing&quot; hreflang=&quot;en&quot;&gt;Installing Policyd&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://imanudin.net/2014/09/09/zimbra-tips-how-to-configure-rate-limit-sending-message-on-policyd/&quot; hreflang=&quot;en&quot;&gt;Configuring Policyd for Zimbra&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://jrklein.com/2014/03/09/debian-wheezy-postfix-cluebringer-policyd-v2-ipv6/&quot; hreflang=&quot;en&quot;&gt;Debian, Cluebringer, IPv6&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
        
              </item>
          <item>
        <title>Configure Postfix as standalone single-domain SMTP server using Unix users and PAM on Debian</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2014/02/01/Configure-Postfix-as-STMP-standalone-single-domain-server-using-Unix-users-and-PAM-on-Debian</link>
        <guid isPermaLink="false">urn:md5:e8f08f8049c5bf438f9d352254044c7f</guid>
        <pubDate>Sat, 01 Feb 2014 22:05:00 +0100</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>debian</category>
                  <category>mail</category>
                  <category>note</category>
                  <category>pam</category>
                  <category>postfix</category>
                  <category>sasl</category>
                  <category>server</category>
                <description>          &lt;p&gt;Here is a quick setup to configure Postfix mail server, using existing Unix users.&lt;/p&gt;

&lt;p&gt;The server will process mails for only one domain, and every existing user on the server will have a mail box inside his home directory.&lt;/p&gt;

&lt;h3&gt;Abstract&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Postfix&lt;/strong&gt; is an &lt;strong&gt;SMTP&lt;/strong&gt; server, it receives incoming mail from other &lt;strong&gt;SMTP&lt;/strong&gt; servers, and allows client to send mails to other &lt;strong&gt;SMTP&lt;/strong&gt; servers.&lt;/p&gt;

&lt;p&gt;What we don't want is an open mail relay. A mail relay is a &lt;strong&gt;SMTP&lt;/strong&gt; server that take anything from any client, and send it to any &lt;strong&gt;SMTP&lt;/strong&gt; server. We only want trusted users to send emails, to prevent anonymous clients from sending spam.&lt;/p&gt;

&lt;p&gt;Incoming mail will be processed either if :&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;The domain name of one of the recipient matches the mail server domain, and the mail user name is also a system user (&lt;strong&gt;SMTP&lt;/strong&gt; servers can send us incoming mails).&lt;/li&gt;
	&lt;li&gt;The client who tries to sends the mail has successfully authenticated.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Postfix&lt;/strong&gt; authentication for clients can be handled by &lt;strong&gt;SASL&lt;/strong&gt;. &lt;strong&gt;SASL&lt;/strong&gt; is a standard protocol to provide an authentication layer. It can query &lt;strong&gt;PAM&lt;/strong&gt;, or other authentication providers (MySQL users, etc).&lt;/p&gt;

&lt;p&gt;Notes :&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;em&gt;We will use PAM for Unix users SMTP authentication.&lt;/em&gt;&lt;/li&gt;
	&lt;li&gt;&lt;em&gt;Unix users are stored in&lt;code&gt; /etc/passwd&lt;/code&gt; and their passwords are stored in &lt;code&gt;/etc/shadow&lt;/code&gt;&lt;/em&gt;.&lt;/li&gt;
	&lt;li&gt;&lt;em&gt;Mails will be stored in the ~/Maildir/ of each users, in Maildir format.&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Postfix : installation and configuration&lt;/h3&gt;

&lt;p&gt;Install Postfix : &lt;code&gt;apt-get install postfix&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Answer the questions during installation to setup your mail domain (the &quot;example.com&quot; in user@example.com).&lt;/p&gt;

&lt;p&gt;Modify config files :&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;/etc/postfix/main.cf&lt;/strong&gt; :&lt;/p&gt;

&lt;p&gt;Configure TLS and Maildir :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;# TLS parameters&lt;br /&gt;
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key&lt;br /&gt;
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem&lt;br /&gt;
smtpd_tls_CAfile = /etc/ssl/certs/ca-certificates.crt&lt;br /&gt;
smtpd_use_tls=yes&lt;br /&gt;
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache&lt;br /&gt;
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache&lt;br /&gt;
&lt;br /&gt;
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for&lt;br /&gt;
# information on enabling SSL in the smtp client.&lt;br /&gt;
&lt;br /&gt;
myhostname = mail.example.com&lt;br /&gt;
alias_maps = hash:/etc/aliases&lt;br /&gt;
alias_database = hash:/etc/aliases&lt;br /&gt;
myorigin = /etc/mailname&lt;br /&gt;
mydestination = example.com, localhost&lt;br /&gt;
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128&lt;br /&gt;
mailbox_size_limit = 0&lt;br /&gt;
recipient_delimiter = +&lt;br /&gt;
&lt;br /&gt;
home_mailbox = Maildir/&lt;br /&gt;
&lt;br /&gt;
# These are the &quot;no relay&quot; restrictions&lt;br /&gt;
smtpd_recipient_restrictions = permit_mynetworks permit_inet_interfaces permit_sasl_authenticated reject_unauth_destination&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;/etc/postfix/master.cf&lt;/strong&gt; :&lt;/p&gt;

&lt;p&gt;Enable TLS and alternate (submission) ports :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;submission inet n&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; smtpd&lt;br /&gt;
&amp;nbsp; -o syslog_name=postfix/submission&lt;br /&gt;
&amp;nbsp; -o smtpd_tls_security_level=encrypt&lt;br /&gt;
&amp;nbsp; -o smtpd_sasl_auth_enable=yes&lt;br /&gt;
&amp;nbsp; -o smtpd_client_restrictions=permit_sasl_authenticated,reject&lt;br /&gt;
&amp;nbsp; -o milter_macro_daemon_name=ORIGINATING&lt;br /&gt;
smtps&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inet&amp;nbsp; n&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; smtpd&lt;br /&gt;
&amp;nbsp; -o syslog_name=postfix/smtps&lt;br /&gt;
&amp;nbsp; -o smtpd_tls_wrappermode=yes&lt;br /&gt;
&amp;nbsp; -o smtpd_sasl_auth_enable=yes&lt;br /&gt;
&amp;nbsp; -o smtpd_client_restrictions=permit_sasl_authenticated,reject&lt;br /&gt;
&amp;nbsp; -o milter_macro_daemon_name=ORIGINATING&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;SASL : installation and configuration&lt;/h3&gt;

&lt;p&gt;SASL plugin for Postfix (Cyrus) is part of the dependencies of Postfix server.&lt;/p&gt;

&lt;p&gt;Install SASL administration tools : &lt;code&gt;apt-get install sasl2-bin&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Enable SASL daemon at startup : edit &lt;strong&gt;/etc/default/saslauthd&lt;/strong&gt; and switch &lt;code&gt;START&lt;/code&gt; to &lt;code&gt;yes&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Start it manually for the first time : &lt;code&gt;service saslauthd start&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;Enable PAM authentication for SASL&lt;/h3&gt;

&lt;p&gt;Check that PAM is part of the MECHANISMS variable in &lt;strong&gt;/etc/default/saslauthd&lt;/strong&gt; :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;MECHANISMS=&quot;pam&quot;&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Create &lt;strong&gt;/etc/pam.d/smtp&lt;/strong&gt; :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;#&lt;br /&gt;
# /etc/pam.d/smtp - specify PAM SMTP behavior&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
@include common-auth&lt;br /&gt;
@include common-account&lt;br /&gt;
@include common-password&lt;br /&gt;
@include common-session&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;Enable SASL for Postfix&lt;/h3&gt;

&lt;p&gt;Add to &lt;strong&gt;/etc/postfix/main.cf&lt;/strong&gt; :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;smtpd_sasl_auth_enable = yes&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Create &lt;strong&gt;/etc/postfix/sasl/smtpd.conf&lt;/strong&gt; :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;pwcheck_method: saslauthd&lt;br /&gt;
mech_list: PLAIN LOGIN&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Adjust &lt;code&gt;OPTIONS&lt;/code&gt; in &lt;strong&gt;/etc/default/saslauthd&lt;/strong&gt; :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;OPTIONS=&quot;-c -m /var/spool/postfix/var/run/saslauthd&quot;&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Add &lt;strong&gt;postfix user&lt;/strong&gt; to &lt;strong&gt;sasl group&lt;/strong&gt; :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;adduser postfix sasl&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;Configuration check&lt;/h3&gt;

&lt;p&gt;Restart all services (postfix, salsauthd).&lt;/p&gt;

&lt;p&gt;Try authentication using SASL : &lt;code&gt;testsaslauthd -u user -p password&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Try authentication from command line, without mail client : &lt;a href=&quot;https://qmail.jms1.net/test-auth.shtml&quot; hreflang=&quot;en&quot;&gt;https://qmail.jms1.net/test-auth.shtml&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Try SMTP reception by sending mail to your domain (your MX fields in domain has to be configured accordingly).&lt;/p&gt;

&lt;h3&gt;Sources&lt;/h3&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;http://www.postfix.org/SASL_README.html#saslauthd&quot; hreflang=&quot;en&quot;&gt;Postfix SASL Howto&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://www.postfix.org/SASL_README.html#testing_saslauthd&quot; hreflang=&quot;en&quot;&gt;Testing SASL auth&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://blog.ntrippy.net/2008/05/warning-sasl-authentication-failure.html&quot; hreflang=&quot;en&quot;&gt;Fixing SASL authentication failure: cannot connect to saslauthd server: No such file or directory&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://www.faqforge.com/linux/how-to-enable-port-587-submission-in-postfix/&quot; hreflang=&quot;en&quot;&gt;How to enable submission ports in Postfix&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://www.howtoforge.com/community/threads/cannot-connect-to-saslauthd-server-permission-denied.22730/&quot; hreflang=&quot;en&quot;&gt;Cannot connect to saslauthd : permission denied&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
        
              </item>
      </channel>
</rss>
