<?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é - spam</title>
    <link>https://uname.pingveno.net/blog/index.php/</link>
    <atom:link href="https://uname.pingveno.net/blog/index.php/feed/tag/spam/rss2" rel="self" type="application/rss+xml" />
    <description>Le blog de uname.pingveno.net</description>
    <language>fr</language>
    <pubDate>Tue, 18 Aug 2026 13:46:21 +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>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>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>Pourquoi mon commentaire n'est pas publié ?</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2014/07/18/Pourquoi-mon-commentaire-n-est-pas-publi%C3%A9</link>
        <guid isPermaLink="false">urn:md5:b0957d95b424770ce7c143c0323c7dfa</guid>
        <pubDate>Fri, 18 Jul 2014 22:56:00 +0200</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Website's life</category>
                          <category>antispam</category>
                  <category>blog</category>
                  <category>commentaire</category>
                  <category>spam</category>
                <description>          &lt;p&gt;Pour mieux lutter contre le SPAM, j'ai modifié il y a quelques semaines le captcha à remplir pour publier un commentaire ou un rétrolien (commentaire sous forme d'article de blog). C'est à présent une question à laquelle il faut répondre &lt;code&gt;courgette&lt;/code&gt; (sans guillemets ni majuscules).&lt;/p&gt;

&lt;p&gt;Pour moi, cela a pour conséquence une réduction drastique du nombre de SPAM qui passaient à côté du précédent système (composé principalement d'un filtre bayésien). Mais pour vous, cela signifie que beaucoup plus de commentaires légitimes peuvent se retrouver bloqués, puisque les filtres sont mis en série. Je réalise des tests pour essayer de réduire le nombre de filtres, peut être ne garder que le principal, qui filtre la très grande majorité des commentaires.&lt;/p&gt;

&lt;p&gt;Mais le but de cet article ce n'est pas de faire de l'autopromotion sur mon système antispam génial. Je me suis rendu compte, ayant à présent plus de temps pour trier les &quot;bon&quot; commentaires, que beaucoup de gens se trompent sur l'objectif du commentaire.&lt;/p&gt;

&lt;p&gt;Si je laisse des commentaires ouvert, ce n'est pas pour que le commentaire que vous écrivez dirige les visiteurs vers votre site ou en fasse une quelconque promotion. Je sélectionne moi-même les blogs ou personnes que je trouve intéressant(e)s, et je les publie dans la barre à droite du blog. Tout commentaire n'apportant rien de concret au fond de l'article et contenant un lien vers un site externe, je ne peux pas le publier, car c'est pour moi une forme de publicité trop facile (vous remarquerez que la publicité est absente de ce blog depuis plusieurs années).&lt;/p&gt;

&lt;p&gt;Votre avis et vos encouragements, même s'ils me font plaisir, je ne peux pas les publier s'ils contreviennent à la règle. Ne m'en voulez pas, je sais que vous avez pris du temps pour l'écrire et ça me va droit au cœur, mais comme je me refuse à modifier les commentaires, je ne peux pas non plus retirer le lien présent pour le publier quand même. Publiez-le sans lien, et il est possible que votre commentaire passe.&lt;/p&gt;

&lt;p&gt;Il y a bien entendu une exception. Si vous publiez un commentaire contenant un lien, et que ce lien est le point de départ d'un enrichissement de l'article à partir du commentaire qui en est fait, alors il y a de très fortes chances qu'il soit publié. Mais beaucoup de gens confondent cet espace d'expression avec un tableau blanc sur lequel on peut faire sa propre promotion.&lt;/p&gt;

&lt;p&gt;Je dois avouer qu'il y a quelques mois, j'ai pensé fermer les commentaires. Mais comme beaucoup de gens n'ont pas d'autres moyens de réagir à mes articles (je ne suis pas présent les réseaux sociaux publics), j'ai laissé les commentaires ouverts et installé le nouveau captcha. Il faut plutôt voir ça comme une chance, les commentaires publiés sont les plus intéressants, il n'y a aucun contenu parasite sur ce blog.&lt;/p&gt;

&lt;p&gt;Une dernière chose à savoir : les commentaires sont modéré à priori. Votre commentaire, s'il passe les filtres, arrive dans une liste où je choisis lesquels je publie, ce n'est pas automatique. Soyez donc patient si vous avez publié un commentaire intéressant, ou alors utilisez le formulaire de contact du blog pour m'en informer.&lt;/p&gt;</description>
        
              </item>
          <item>
        <title>Nobody loves me. But spammers does !</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2013/06/25/Nobody-loves-me.-But-spammers-does-%21</link>
        <guid isPermaLink="false">urn:md5:05e78a97b4d28f3942c7884bc7370b4d</guid>
        <pubDate>Tue, 25 Jun 2013 22:54:00 +0200</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Humour</category>
                          <category>humour</category>
                  <category>informaticien</category>
                  <category>spam</category>
                <description>&lt;p&gt;Billet d&amp;#8217;humour et d&amp;#8217;humeur, ne pas comprendre prouvera que vous êtes normal. &lt;img src=&quot;/blog/themes/mathedit_material3/smilies/smile.png&quot; alt=&quot;:)&quot; class=&quot;smiley&quot;&gt;&lt;/p&gt;          &lt;p&gt;&lt;blockquote&gt;&lt;p&gt;Definitely consider that that you said. Your favourite reason seemed
to be on the net the easiest factor to keep in mind of. I say to you, I
certainly get annoyed even as people consider worries that they just do
not realize about. &lt;strong&gt;You managed to hit the nail upon the highest&lt;/strong&gt; as
neatly as outlined out the entire thing without having side effect ,
other folks could take a signal. &lt;strong&gt;Will likely be back to get more. Thank
you&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;&lt;/p&gt;
&lt;p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;strong&gt;Thanks&lt;/strong&gt; , I’ve just been searching for info approximately this topic
for a long time and &lt;strong&gt;yours is the greatest&lt;/strong&gt; I’ve came upon &lt;strong&gt;so far&lt;/strong&gt;.
However, what in regards to the conclusion? Are you sure in regards to
the source?|What i do not realize is if truth be told how you are no
longer really a lot more neatly-liked than you might be now. &lt;strong&gt;You’re so
intelligent&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;&lt;/p&gt;
&lt;p&gt;&lt;blockquote&gt;&lt;p&gt;You can absolutely visit interest inside function you’re writing.
Your segment &lt;strong&gt;desires of more ardent freelancers just like you&lt;/strong&gt; who aren’t
frightened to mention the way they feel. At all times focus on a
person’s soul.&lt;/p&gt;
&lt;/blockquote&gt;&lt;/p&gt;
&lt;p&gt;&lt;blockquote&gt;&lt;p&gt;You could definitely &lt;strong&gt;see your skills within the paintings you write&lt;/strong&gt;.
The world hopes for &lt;strong&gt;more passionate writers such as you&lt;/strong&gt; who are not
afraid to mention how they believe. All the time go after your heart.&lt;/p&gt;
&lt;/blockquote&gt;&lt;/p&gt;
&lt;p&gt;&lt;blockquote&gt;&lt;p&gt;Woah &lt;strong&gt;the following blog site is fantastic&lt;/strong&gt; i favor examining the
articles you write. Maintain the great function! You are aware of, many
people are seeking circular with this information and facts, you may
help them drastically.&lt;/p&gt;
&lt;/blockquote&gt;&lt;/p&gt;
&lt;p&gt;&lt;blockquote&gt;&lt;p&gt;Woah this weblog can be magnificent &lt;strong&gt;i enjoy learning the articles you
write&lt;/strong&gt;. Be the great! You recognize, plenty of people need about with
this information and facts, you may assist them to enormously.&lt;/p&gt;
&lt;/blockquote&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Bon allez, stop, point trop n&amp;#8217;en faut, j&amp;#8217;en ai des centaines comme ça. &lt;img src=&quot;/blog/themes/mathedit_material3/smilies/wink.png&quot; alt=&quot;;)&quot; class=&quot;smiley&quot;&gt;&lt;/p&gt;</description>
        
              </item>
      </channel>
</rss>
