{
    "version": "https:\/\/jsonfeed.org\/version\/1.1",
    "title": "IT science: заметки с тегом Postfix",
    "_rss_description": "IT science — статьи и инструкции из мира IT",
    "_rss_language": "ru",
    "_itunes_email": "",
    "_itunes_categories_xml": "",
    "_itunes_image": "",
    "_itunes_explicit": "",
    "home_page_url": "https:\/\/itscience.pro\/tags\/postfix\/",
    "feed_url": "https:\/\/itscience.pro\/tags\/postfix\/json\/",
    "icon": "https:\/\/itscience.pro\/pictures\/userpic\/userpic@2x.jpg?1658757154",
    "authors": [
        {
            "name": "IT science",
            "url": "https:\/\/itscience.pro\/",
            "avatar": "https:\/\/itscience.pro\/pictures\/userpic\/userpic@2x.jpg?1658757154"
        }
    ],
    "items": [
        {
            "id": "45",
            "url": "https:\/\/itscience.pro\/all\/chistim-pochtovy-server-ot-staryh-rassylok\/",
            "title": "Чистим почтовый сервер от старых рассылок",
            "content_html": "<p>Что-то много мусора накопилось в ящиках пользователей.<br \/>\nМожно удалить старые письма (рассылки), которые потеряли свою актуальность.<\/p>\n<p>Опираться будем на уникальное содержимое письма. И возраст файла.<\/p>\n<p>например, ищем строку «Return-Path: <user@domain.ru>»<br \/>\nи пусть, файл будет страше 30 дней<\/p>\n<p>получается скрипт:<\/p>\n<pre class=\"e2-text-code\"><code class=\"\">find \/var\/vmail\/ -type f -mtime +30 -exec grep -Ilr &quot;Return-Path: &lt;user@domain.ru&gt;&quot;  {} \\;<\/code><\/pre><p>где «\/var\/vmail\/» — путь к хранилищу писем<\/p>\n<p>выполнив эту команду получим список нужных нам файлов, без удаления<\/p>\n<p>а теперь, просто допишем в конец команду для удаления<\/p>\n<pre class=\"e2-text-code\"><code class=\"\">find \/var\/vmail\/ -type f -mtime +30 -exec grep -Ilr &quot;Return-Path: &lt;user@domain.ru&gt;&quot;  {} \\; | xargs rm<\/code><\/pre><p>всё<\/p>\n",
            "date_published": "2022-09-06T10:49:01+03:00",
            "date_modified": "2022-09-06T10:48:54+03:00",
            "tags": [
                "find",
                "linux",
                "Postfix"
            ],
            "_date_published_rfc2822": "Tue, 06 Sep 2022 10:49:01 +0300",
            "_rss_guid_is_permalink": "false",
            "_rss_guid": "45",
            "_e2_data": {
                "is_favourite": false,
                "links_required": [
                    "highlight\/highlight.js",
                    "highlight\/highlight.css"
                ],
                "og_images": []
            }
        },
        {
            "id": "30",
            "url": "https:\/\/itscience.pro\/all\/lechim-pochtovye-vlozheniya-winmail-dat\/",
            "title": "лечим почтовые вложения winmail.dat",
            "content_html": "<p>Проблема древняя и как водится связана с попыткой Microsoft навязывать свои стандарты. Откуда берется почтовое вложение winmail.dat вы можете почитать тут: <a href=\"https:\/\/support.mozilla.org\/ru\/kb\/chto-oznachaet-vlozhenie-winmaildat\">https:\/\/support.mozilla.org\/ru\/kb\/chto-oznachaet-vlozhenie-winmaildat<\/a><\/p>\n<p>сегодня мы решим эту проблему глобально, прокачаем наш postfix сервер<\/p>\n<ol start=\"1\">\n<li>Установим MIMEDefang.<\/li>\n<\/ol>\n<blockquote>\n<p>для CentOS<\/p>\n<\/blockquote>\n<pre class=\"e2-text-code\"><code class=\"\">yum install mimedefang<\/code><\/pre><blockquote>\n<p>для Ubuntu<\/p>\n<\/blockquote>\n<pre class=\"e2-text-code\"><code class=\"\">apt-get install mimedefang<\/code><\/pre><ol start=\"2\">\n<li>Настроим MIMEDefang на определенный порт TCP, наша служба будет слушать этот порт. Для этого исправим конфигурацию<\/li>\n<\/ol>\n<blockquote>\n<p>для CentOS: \/etc\/sysconfig\/mimedefang<br \/>\nдля Ubuntu: \/etc\/default\/mimedefang<\/p>\n<\/blockquote>\n<blockquote>\n<p>дописываем в конце<\/p>\n<\/blockquote>\n<pre class=\"e2-text-code\"><code class=\"\">SOCKET=inet:10185<\/code><\/pre><ol start=\"3\">\n<li>Отредактируем файл  <b>\/etc\/mail\/mimedefang-filter<\/b>, можете просто вставить текст ниже<\/li>\n<\/ol>\n<pre class=\"e2-text-code\"><code class=\"\"># -*- Perl -*-\n#***********************************************************************\n#\n# mimedefang-filter\n#\n# Suggested minimum-protection filter for Microsoft Windows clients, plus\n# SpamAssassin checks if SpamAssassin is installed.\n#\n# Copyright (C) 2002 Roaring Penguin Software Inc.\n#\n# This program may be distributed under the terms of the GNU General\n# Public License, Version 2, or (at your option) any later version.\n#\n# $Id$\n#***********************************************************************\n\n#***********************************************************************\n# Set administrator&#039;s e-mail address here.  The administrator receives\n# quarantine messages and is listed as the contact for site-wide\n# MIMEDefang policy.  A good example would be &#039;defang-admin@mydomain.com&#039;\n#***********************************************************************\n$AdminAddress = &#039;postmaster@localhost&#039;;\n$AdminName = &quot;MIMEDefang Administrator&#039;s Full Name&quot;;\n\n#***********************************************************************\n# Set the e-mail address from which MIMEDefang quarantine warnings and\n# user notifications appear to come.  A good example would be\n# &#039;mimedefang@mydomain.com&#039;.  Make sure to have an alias for this\n# address if you want replies to it to work.\n#***********************************************************************\n$DaemonAddress = &#039;mimedefang@localhost&#039;;\n\n#***********************************************************************\n# If you set $AddWarningsInline to 1, then MIMEDefang tries *very* hard\n# to add warnings directly in the message body (text or html) rather\n# than adding a separate &quot;WARNING.TXT&quot; MIME part.  If the message\n# has no text or html part, then a separate MIME part is still used.\n#***********************************************************************\n$AddWarningsInline = 0;\n\n#***********************************************************************\n# To enable syslogging of virus and spam activity, add the following\n# to the filter:\n# md_graphdefang_log_enable();\n# You may optionally provide a syslogging facility by passing an\n# argument such as:  md_graphdefang_log_enable(&#039;local4&#039;);  If you do this, be\n# sure to setup the new syslog facility (probably in \/etc\/syslog.conf).\n# An optional second argument causes a line of output to be produced\n# for each recipient (if it is 1), or only a single summary line\n# for all recipients (if it is 0.)  The default is 1.\n# Comment this line out to disable logging.\n#***********************************************************************\nmd_graphdefang_log_enable(&#039;mail&#039;, 1);\n\n#***********************************************************************\n# Uncomment this to block messages with more than 50 parts.  This will\n# *NOT* work unless you&#039;re using Roaring Penguin&#039;s patched version\n# of MIME tools, version MIME-tools-5.411a-RP-Patched-02 or later.\n#\n# WARNING: DO NOT SET THIS VARIABLE unless you&#039;re using at least\n# MIME-tools-5.411a-RP-Patched-02; otherwise, your filter will fail.\n#***********************************************************************\n# $MaxMIMEParts = 50;\n\n#***********************************************************************\n# Set various stupid things your mail client does below.\n#***********************************************************************\n\n# Set the next one if your mail client cannot handle multiple &quot;inline&quot;\n# parts.\n$Stupidity{&quot;NoMultipleInlines&quot;} = 0;\n\n# Detect and load Perl modules\ndetect_and_load_perl_modules();\n\n\nsub filter {\n    my($entity, $fname, $ext, $type) = @_;\n \n    ### Convert TNEF winmail.dat format\n    ### Note: You must install Convert::TNEF and File::Type from CPAN before using this script\n    if (lc($type) eq &quot;application\/ms-tnef&quot; or lc($fname) eq &quot;winmail.dat&quot; ) {\n        use Convert::TNEF;\n        use File::Type;\n        use File::Temp qw(tempfile tempdir);\n \n        # Create a unique temporary directory under &quot;\/tmp&quot;\n        my $tnefdir = tempdir(CLEANUP =&gt; 1, DIR =&gt; &quot;\/tmp&quot;);\n        if (not $tnefdir) {\n                md_graphdefang_log(&#039;tnef_fail&#039;,&quot;Unable to create temporary directory&quot;);\n                return action_accept();\n        }\n \n        # If we can&#039;t Convert the TNEF file for some reason, just accept the attachment and log the error\n        my $tnef = Convert::TNEF-&gt;read_ent($entity,{output_dir=&gt;&quot;$tnefdir&quot;});\n        if (not $tnef) {\n                md_graphdefang_log(&#039;tnef_fail&#039;,$Convert::TNEF::errstr);\n                return action_accept();\n        }\n \n        my $ft = File::Type-&gt;new();\n \n        # Append attachments contained in the winmail.dat file to the message.\n        for ($tnef-&gt;attachments) {\n             # Determine the mime-type of the file\n             my $mimetype = $ft-&gt;mime_type($_-&gt;data);\n \n                # File::Type doesn&#039;t detect text files well, this is a workaround\n             if ($mimetype eq &quot;application\/octet-stream&quot;) {\n                  #Set the mime-type to text\/plain if the first 1024 characters are printable\n                  $text_check = substr($_-&gt;data,0,1024);\n                  $mimetype = &quot;text\/plain&quot; unless $text_check =~ \/[^[:print:]s]\/;\n             }\n \n             my $tnef_entity = action_add_part($entity, &quot;$mimetype&quot;, &quot;base64&quot;, $_-&gt;data, $_-&gt;longname, &quot;attachment&quot;);\n             md_graphdefang_log(&#039;tnef_ext&#039;, &quot;File: &quot; . $_-&gt;longname . &quot; Type: $mimetype&quot;);\n \n             # Run each new TNEF-sourced MIME part back through the filter again, this ensures that bad filenames etc.\n             # cannot sneak through by being contained in winmail.dat files\n \n             filter ($tnef_entity, $_-&gt;longname, &quot;&quot;, &quot;$mimetype&quot;);\n        }\n \n        # Deletes working files\n        $tnef-&gt;purge;\n\n \n        # Remark this if you want still want to keep the original winmail.dat file\n        return action_drop();\n    }\n \n    # Keep the attachment\n    return action_accept();\n}\n\n# DO NOT delete the next line, or Perl will complain.\n1;<\/code><\/pre><ol start=\"4\">\n<li>Установим модели Perl  <b>Convert::TNEF<\/b> и <b>File::Type<\/b><\/li>\n<\/ol>\n<blockquote>\n<p>для CentOS<\/p>\n<\/blockquote>\n<pre class=\"e2-text-code\"><code class=\"\">yum install perl-Convert-TNEF.noarch<\/code><\/pre><blockquote>\n<p>второй пакет надо скачать и установить<\/p>\n<\/blockquote>\n<pre class=\"e2-text-code\"><code class=\"\">wget https:\/\/ftp.tu-chemnitz.de\/pub\/linux\/dag\/redhat\/el6\/en\/x86_64\/rpmforge\/RPMS\/perl-File-Type-0.22-1.el6.rf.noarch.rpm<\/code><\/pre><pre class=\"e2-text-code\"><code class=\"\">yum install perl-File-Type-0.22-1.el6.rf.noarch.rpm<\/code><\/pre><blockquote>\n<p>для Ubuntu<\/p>\n<\/blockquote>\n<pre class=\"e2-text-code\"><code class=\"\">apt-get install libconvert-tnef-perl<\/code><\/pre><pre class=\"e2-text-code\"><code class=\"\">apt-get install libfile-type-perl<\/code><\/pre><ol start=\"5\">\n<li>Проверим синтаксис Perl<\/li>\n<\/ol>\n<pre class=\"e2-text-code\"><code class=\"\"># perl -c \/etc\/mail\/mimedefang-filter<\/code><\/pre><ol start=\"6\">\n<li>Настроим автозапуск службы MIMEDefang и запустим ее<\/li>\n<\/ol>\n<pre class=\"e2-text-code\"><code class=\"\">systemctl enable mimedefang.service<\/code><\/pre><pre class=\"e2-text-code\"><code class=\"\">service mimedefang restart<\/code><\/pre><ol start=\"7\">\n<li>Проверим, слушает ли сервис указанный выше порт<\/li>\n<\/ol>\n<pre class=\"e2-text-code\"><code class=\"\"># netstat -tlpn | grep 10185\ntcp        0      0 0.0.0.0:10185           0.0.0.0:*               LISTEN      7401\/mimedefang<\/code><\/pre><ol start=\"8\">\n<li>Теперь добавим проверку в Postfix, для этого откроем конфиг <b>\/etc\/postfic\/main.cf<\/b><\/li>\n<\/ol>\n<blockquote>\n<p>и допишем в конце<\/p>\n<\/blockquote>\n<pre class=\"e2-text-code\"><code class=\"\">smtpd_milters = inet:localhost:10185\nmilter_default_action = accept<\/code><\/pre><p>готово! Любое письмо, которое будет иметь во вложении winmail.dat, будет обработано нашей службой и вложение будет расшифровано!<\/p>\n",
            "date_published": "2020-12-21T11:47:09+03:00",
            "date_modified": "2020-12-21T11:46:58+03:00",
            "tags": [
                "MIMEDefang",
                "Perl",
                "Postfix",
                "winmail.dat"
            ],
            "_date_published_rfc2822": "Mon, 21 Dec 2020 11:47:09 +0300",
            "_rss_guid_is_permalink": "false",
            "_rss_guid": "30",
            "_e2_data": {
                "is_favourite": false,
                "links_required": [
                    "highlight\/highlight.js",
                    "highlight\/highlight.css"
                ],
                "og_images": []
            }
        },
        {
            "id": "25",
            "url": "https:\/\/itscience.pro\/all\/mail-server-i-mail-station\/",
            "title": "Mail Server и Mail Station",
            "content_html": "<p>Из бесплатных решений у synology есть два пакета, почтовый сервер на базе Postfix и пользовательский web клиент.<\/p>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/itscience.pro\/pictures\/mail01.PNG\" width=\"800\" height=\"168.98656898657\" alt=\"\" \/>\n<\/div>\n<p>давайте рассмотрим функционал сервера<\/p>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/itscience.pro\/pictures\/mail02.PNG\" width=\"800\" height=\"504.44624090542\" alt=\"\" \/>\n<\/div>\n<ul>\n<li>есть поддержка как локальных пользователей, так и доменных (есть возможность использовать как корпоративное решение)<\/li>\n<li>использование основного домена и элиасов, т. е. пользователь автоматически получает почту с адресов user@domain.ru, user@aliase.ru и т. д.<\/li>\n<\/ul>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/itscience.pro\/pictures\/mail03.PNG\" width=\"800\" height=\"506.39511201629\" alt=\"\" \/>\n<\/div>\n<ul>\n<li>поддержка протоколов как IMAP, так и POP3<\/li>\n<li>обратите внимание на использование ssl, этот важный бонус вы оцените позже<\/li>\n<\/ul>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/itscience.pro\/pictures\/mail04.PNG\" width=\"800\" height=\"433.84494293585\" alt=\"\" \/>\n<\/div>\n<p>безопасность прокачена просто на высоте, есть возможность использовать все современные технологии<\/p>\n<ul>\n<li>защита от СПАМа с использованием модуля SpamAssassin<\/li>\n<li>поддержка блэклистов DNSBL<\/li>\n<\/ul>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/itscience.pro\/pictures\/mail05.PNG\" width=\"800\" height=\"428.51516345018\" alt=\"\" \/>\n<\/div>\n<ul>\n<li>есть возможность включить антивирус на базе ClamAV, я не включаю, т. к. значительно тратится память, а эффективность под вопросом, чаще происходят ложные срабатывания<\/li>\n<\/ul>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/itscience.pro\/pictures\/mail06.PNG\" width=\"800\" height=\"427.59164367363\" alt=\"\" \/>\n<\/div>\n<ul>\n<li>можно создавать чёрные и белые списки, глобально для всех пользователей сервера, кстати очень гибкий редактор, см. ниже<\/li>\n<li>можно установить ежедневные квоты на отправку сообщений, можно общее значение, можно индивидуально пользователям, удобно если чей-то ящик взломают — это не перерастет в лавинную отправку спама<\/li>\n<li>фильтр вложений, можно задать запрещенные расширения файлов для пересылки (по-умолчанию, присутствует список самых распространенных исполняемых файлов)<\/li>\n<\/ul>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/itscience.pro\/pictures\/mail07.PNG\" width=\"800\" height=\"543.23144104803\" alt=\"\" \/>\n<\/div>\n<p>подробнее настройка чёрного и белого списка, обратите внимание на возможности делать исключения<\/p>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/itscience.pro\/pictures\/mail08.PNG\" width=\"800\" height=\"448.51837218491\" alt=\"\" \/>\n<\/div>\n<p>реализована защита от вредоносного содержимого письма, так же все настраивается<\/p>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/itscience.pro\/pictures\/mail09.PNG\" width=\"800\" height=\"547.05184012663\" alt=\"\" \/>\n<\/div>\n<p>и самое, на мой взгляд, важное, это настройки SPF,  DKIM и защита DMARK, сейчас современный почтовый сервер не может существовать без всего этого<br \/>\nесли вы не знаете, что это такое — не беда, открываете Справку и читаете как правильно настроить DNS<\/p>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/itscience.pro\/pictures\/mail11.PNG\" width=\"800\" height=\"448.63366336634\" alt=\"\" \/>\n<\/div>\n<p>да, Справка в Synology очень крутая!<\/p>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/itscience.pro\/pictures\/mail10.PNG\" width=\"800\" height=\"429.69984202212\" alt=\"\" \/>\n<\/div>\n<p>есть возможность использовать псевдонимы не только внутренних пользователей, а можно настроить пересылку на внешние ящики, это круто<\/p>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/itscience.pro\/pictures\/mail12.PNG\" width=\"800\" height=\"436.21984974298\" alt=\"\" \/>\n<\/div>\n<p>автоматическая скрытая копия, это что-то из области слежения<\/p>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/itscience.pro\/pictures\/mail13.PNG\" width=\"800\" height=\"421.88739095956\" alt=\"\" \/>\n<\/div>\n<p>таблица с текущей очередью сообщений, с возможностью удаления, повторной отправки и очистки сообщений<\/p>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/itscience.pro\/pictures\/mail14.PNG\" width=\"800\" height=\"449.4275562574\" alt=\"\" \/>\n<\/div>\n<p>журнал, полезная вещь, можно сразу увидеть было ли доставлено сообщение и когда, а также ошибки отправки, самое же важное, на мой взгляд, это возможность выгрузить лог postfix, сам пользовался и не раз<\/p>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/itscience.pro\/pictures\/mail15.PNG\" width=\"800\" height=\"458.45909451946\" alt=\"\" \/>\n<\/div>\n<p>довольно подробный в текстовом формате отчет об отправленных, полученных, заблокированных сообщений, можно настроить получение на любой ящик<\/p>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/itscience.pro\/pictures\/mail16.PNG\" width=\"800\" height=\"431.45001975504\" alt=\"\" \/>\n<\/div>\n<p>настройка пересылки, автоответа и т. д. с поддержкой глобальных переменных<\/p>\n<p>Подведем итог, это бесплатная версия сервера (позже расскажу про платную), на мой взгляд реализован функционал современного почтового сервера на 95%. Есть все самые основные вещи, и работает сразу из коробки, не нужны «танцы с бубном». Очень удобный интерфейс управления. Рекомендую как частный почтовый сервер, до корпоративного не хватает адресной книги с возможностью делиться контактами и расшаривания почтовых папок.<\/p>\n<p>PS обещал рассказать про ssl, когда вы настроите домен, пропишите в DNS адрес сервера, то с помощью synology сможете выпустить заверенные сертификаты Let’s Encrypt для IMAP, SMTP и POP3, в будущем synology будет автоматически перевыпускать эти сертификаты, т. е. настроили и забыли<\/p>\n<p>Mail Station — это почтовый web-клиент RoundCube (<a href=\"https:\/\/roundcube.net).\">https:\/\/roundcube.net).<\/a> очень урезанный, без возможности отмечать сообщения как СПАМ, но в целом годный<\/p>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/itscience.pro\/pictures\/mail17.PNG\" width=\"800\" height=\"496.09467455621\" alt=\"\" \/>\n<\/div>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/itscience.pro\/pictures\/mail18.PNG.jpg\" width=\"800\" height=\"173.4375\" alt=\"\" \/>\n<\/div>\n<p>т. к. RoundCube можно неплохо прокачать за счет огромного количества плагинов, то все в ваших руках<\/p>\n",
            "date_published": "2020-04-08T13:50:02+03:00",
            "date_modified": "2020-04-08T13:49:13+03:00",
            "tags": [
                "ClamAV",
                "DKIM",
                "DMARK",
                "DNSBL",
                "IMAP",
                "Mail Server",
                "Mail Station",
                "Postfix",
                "RoundCube",
                "SMTP",
                "SpamAssassin",
                "SPF"
            ],
            "image": "https:\/\/itscience.pro\/pictures\/mail01.PNG",
            "_date_published_rfc2822": "Wed, 08 Apr 2020 13:50:02 +0300",
            "_rss_guid_is_permalink": "false",
            "_rss_guid": "25",
            "_e2_data": {
                "is_favourite": false,
                "links_required": [],
                "og_images": [
                    "https:\/\/itscience.pro\/pictures\/mail01.PNG",
                    "https:\/\/itscience.pro\/pictures\/mail02.PNG",
                    "https:\/\/itscience.pro\/pictures\/mail03.PNG",
                    "https:\/\/itscience.pro\/pictures\/mail04.PNG",
                    "https:\/\/itscience.pro\/pictures\/mail05.PNG",
                    "https:\/\/itscience.pro\/pictures\/mail06.PNG",
                    "https:\/\/itscience.pro\/pictures\/mail07.PNG",
                    "https:\/\/itscience.pro\/pictures\/mail08.PNG",
                    "https:\/\/itscience.pro\/pictures\/mail09.PNG",
                    "https:\/\/itscience.pro\/pictures\/mail11.PNG",
                    "https:\/\/itscience.pro\/pictures\/mail10.PNG",
                    "https:\/\/itscience.pro\/pictures\/mail12.PNG",
                    "https:\/\/itscience.pro\/pictures\/mail13.PNG",
                    "https:\/\/itscience.pro\/pictures\/mail14.PNG",
                    "https:\/\/itscience.pro\/pictures\/mail15.PNG",
                    "https:\/\/itscience.pro\/pictures\/mail16.PNG",
                    "https:\/\/itscience.pro\/pictures\/mail17.PNG",
                    "https:\/\/itscience.pro\/pictures\/mail18.PNG.jpg"
                ]
            }
        }
    ],
    "_e2_version": 4171,
    "_e2_ua_string": "Aegea 11.4 (v4171)"
}