<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>postfix &amp;mdash; LinuxPizza</title>
    <link>https://blogs.linux.pizza/tag:postfix</link>
    <description>Personal notes and occasional posts - 100% human, 0% AI generated</description>
    <pubDate>Tue, 14 Apr 2026 15:33:59 +0000</pubDate>
    <item>
      <title>Postfix - relay emails via a another mailserver with authentication and submission enabled</title>
      <link>https://blogs.linux.pizza/postfix-relay-emails-via-a-another-mailserver-with-authentication-and</link>
      <description>&lt;![CDATA[This short writeup will guide you on how to do it on Debian-based and Fedora systems.&#xA;&#xA;We begin with installing posfix and the required packages for authentication.&#xA;&#xA;First - doublecheck that your machine has a Fully Qualified Domain Name set in the hostfile, this will remove alot of headaches from you in the future.&#xA;&#xA;My machine is named &#34;T15.domain.tld&#34; - so emails will be arriving from &#34;user@T15.domain.tld&#34;.&#xA;&#xA;Debian:&#xA;apt-get install postfix mailutils libsasl2-2 libsasl2-modules&#xA;Fedora:&#xA;dnf install postfix mailx mailx cyrus-sasl cyrus-sasl-plain&#xA;Next, we will create the sasl-password file and hash it:&#xA;echo &#34;[relay.domain.tld]:587 username:password&#34;   /etc/postfix/sasl&#xA;postmap /etc/postfix/sasl&#xA;Great, now we have to tell postfix that all emails sent via it should be relayed throu the smtp-relay:&#xA;relayhost = [relay.domain.tld]:587&#xA;smtpusetls = yes&#xA;smtpsaslauthenable = yes&#xA;smtpsaslsecurityoptions =&#xA;smtpsaslpasswordmaps = hash:/etc/postfix/sasl&#xA;smtptlsCAfile = /etc/ssl/certs/ca-certificates.crt&#xA;Restart postfix and check the log, so everything looks good.&#xA;&#xA;Test your setup:&#xA;echo &#34;This is a test&#34; | mail -s &#34;Just a test&#34; destinationemail@domain.tld&#xA;You can check the status of the mailqueue with the command &#xA;And that&#39;s about it!&#xA;&#xA;#linux #postfix #smtp #sysadmin #email]]&gt;</description>
      <content:encoded><![CDATA[<h4 id="this-short-writeup-will-guide-you-on-how-to-do-it-on-debian-based-and-fedora-systems" id="this-short-writeup-will-guide-you-on-how-to-do-it-on-debian-based-and-fedora-systems">This short writeup will guide you on how to do it on Debian-based and Fedora systems.</h4>

<p>We begin with installing posfix and the required packages for authentication.</p>

<p>First – doublecheck that your machine has a Fully Qualified Domain Name set in the hostfile, this will remove alot of headaches from you in the future.</p>

<p>My machine is named “T15.domain.tld” – so emails will be arriving from “user@T15.domain.tld”.</p>

<p>Debian:</p>

<pre><code>apt-get install postfix mailutils libsasl2-2 libsasl2-modules
</code></pre>

<p>Fedora:</p>

<pre><code>dnf install postfix mailx mailx cyrus-sasl cyrus-sasl-plain
</code></pre>

<p>Next, we will create the sasl-password file and hash it:</p>

<pre><code>echo &#34;[relay.domain.tld]:587 username:password&#34; &gt; /etc/postfix/sasl
postmap /etc/postfix/sasl
</code></pre>

<p>Great, now we have to tell postfix that all emails sent via it should be relayed throu the smtp-relay:</p>

<pre><code>relayhost = [relay.domain.tld]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_security_options =
smtp_sasl_password_maps = hash:/etc/postfix/sasl
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
</code></pre>

<p>Restart postfix and check the log, so everything looks good.</p>

<p>Test your setup:</p>

<pre><code>echo &#34;This is a test&#34; | mail -s &#34;Just a test&#34; destination_email@domain.tld
</code></pre>

<p>You can check the status of the mailqueue with the command <code>mailq</code>.</p>

<p>And that&#39;s about it!</p>

<p><a href="https://blogs.linux.pizza/tag:linux" class="hashtag"><span>#</span><span class="p-category">linux</span></a> <a href="https://blogs.linux.pizza/tag:postfix" class="hashtag"><span>#</span><span class="p-category">postfix</span></a> <a href="https://blogs.linux.pizza/tag:smtp" class="hashtag"><span>#</span><span class="p-category">smtp</span></a> <a href="https://blogs.linux.pizza/tag:sysadmin" class="hashtag"><span>#</span><span class="p-category">sysadmin</span></a> <a href="https://blogs.linux.pizza/tag:email" class="hashtag"><span>#</span><span class="p-category">email</span></a></p>
]]></content:encoded>
      <guid>https://blogs.linux.pizza/postfix-relay-emails-via-a-another-mailserver-with-authentication-and</guid>
      <pubDate>Sat, 10 Sep 2022 18:41:49 +0000</pubDate>
    </item>
    <item>
      <title>Deploying OpenDMARC on your Postfix mailserver</title>
      <link>https://blogs.linux.pizza/deploying-opendmarc-on-your-postfix-mailserver</link>
      <description>&lt;![CDATA[As a MTA lover, I always try to encourage people (especially &#34;IT-people&#34;) to host their own mailserver. Mostly so they actually can learn something and also that I do not like how the big providers like Google, Microsoft, Amazon etc keep eating up the market.&#xA;Diversity is a key to a healthy market - but that is another topic.&#xA;&#xA;This guide will mostly apply to Debian-based distros like Debian (9 or newer), Ubuntu (16.04 or newer) or any other &#34;serverdistro&#34;. I do assume that you already have a working mailserver that do both deliver and receive emails that are DKIM signed (or atleast perform validation with OpenDKIM), otherwhise you can read my short guide here (coming soon).&#xA;&#xA;First, install OpenDMARC from the repository.&#xA;apt update&#xA;apt install opendmarc -y&#xA;Verify that the user and group opendmarc has been created by checking /etc/passwd and /etc/group. Otherwhise, create them.&#xA;When you have installed it, verify the installation by running this:&#xA;opendmarc -V&#xA;You will get something like this (the version number is not that important yet):&#xA;opendmarc: OpenDMARC Filter v1.3.2       &#xA;    SMFIVERSION 0x1000001       &#xA;    libmilter version 1.0.1       &#xA;    Active code options:               &#xA;    WITHSPF               &#xA;    WITHSPF2&#xA;&#xA;Great! Let&#39;s proceed to configuring opendmarc&#xA;First, take a backup of the current opendmarc.conf, it will save some headache in the future if you want to redo it:&#xA;cp /etc/opendmarc.conf /etc/opendmarc.conf.BAK&#xA;Edit /etc/opendmarc.conf with the following:&#xA;AuthservID [SERVERHOSTNAME]&#xA;FailureReports true&#xA;PidFile /var/run/opendmarc.pid&#xA;RejectFailures false&#xA;SPFSelfValidate yes&#xA;Socket inet:8893@localhost&#xA;SoftwareHeader true&#xA;Syslog true&#xA;SyslogFacility mail&#xA;TrustedAuthservIDs [SERVERHOSTNAME]&#xA;HistoryFile /var/run/opendmarc/opendmarc.dat&#xA;UMask 0002&#xA;UserID opendmarc&#xA;Dont forget to restart opendmarc&#xA;service opendmarc restart &#xA;Proceed with adding opendmarc as a milter in postfix. I am assuming that you already have opendkim enabled as a milter like this:&#xA;smtpdmilters = inet:localhost:8891&#xA;nonsmtpdmilters = inet:localhost:8891&#xA;We now need to add the opendmarc milter into the postfix configuration, it is important that you add it AFTER the opendkim milter, otherwhise opendmarc will not be able to check if the DKIM key is valid.&#xA;smtpdmilters = inet:localhost:8891,inet:localhost:8893&#xA;nonsmtpdmilters = inet:localhost:8891,inet:localhost:8893&#xA;milterdefaultaction = accept&#xA;The last one is pretty important, so if one of your milters does not work for some reason - Postfix will still let it throu.&#xA;Restart postfix&#xA;service postfix restart&#xA;We should now be able to test the configuration by sending an email from example a gmail.com account to an email address on your email-server and check your logs if opendmarc actually works.&#xA;tail -f /var/log/mail.log | grep &#34;opendmarc&#34;&#xA;You should be able to see this:&#xA;Apr 26 12:16:38 mx opendmarc[31490]: 5155751C32: SPF(mailfrom): dmarctest@linux.pizza pass&#xA;Apr 26 12:16:39 mx opendmarc[31490]: 5155751C32: linux.pizza pass&#xA;Great! Your server does now validate DMARC policies! If you just wanted this basic functionality, you are done now.&#xA;But there is always room for improvement!&#xA;&#xA;Adding a Public-suffix list&#xA;This can be achieved in the following simple steps:&#xA;Create a catalogue (and change ownership) for the list to be downloaded to:&#xA;mkdir -p /etc/opendmarc/&#xA;chown opendmarc: /etc/opendmarc&#xA;Set up a cronjob to download the suffix list once a week&#xA;crontab -u opendmarc -e&#xA;And this line:&#xA;@weekly/usr/bin/wget -k -q -N -P /etc/opendmarc https://publicsuffix.org/list/effectivetldnames.dat&#xA;Also, just download the list so you have it before you configure opendmarc to use it:&#xA;wget -k -q -N -P /etc/opendmarc https://publicsuffix.org/list/effectivetldnames.dat &#xA;Finally, configure opendmarc to actually use that list, put this on the bottom in /etc/opendmarc.conf and restart opendmarc&#xA;PublicSuffixList /etc/opendmarc/effectivetld_names.dat&#xA;service opendmarc restart &#xA;&#xA;Awesome! You are now done with the OpenDMARC.&#xA;Next up - adding DMARC reporting, this will be in an upcoming post.&#xA;&#xA;#postfix #dmarc #opendmarc #smtp #email #linux]]&gt;</description>
      <content:encoded><![CDATA[<p>As a MTA lover, I always try to encourage people (especially “IT-people”) to host their own mailserver. Mostly so they actually can learn something and also that I do not like how the big providers like Google, Microsoft, Amazon etc keep eating up the market.
Diversity is a key to a healthy market – but that is another topic.</p>

<p>This guide will mostly apply to Debian-based distros like Debian (9 or newer), Ubuntu (16.04 or newer) or any other “serverdistro”. I do assume that you already have a working mailserver that do both deliver and receive emails that are DKIM signed (or atleast perform validation with OpenDKIM), otherwhise you can read my short guide here (coming soon).</p>

<h3 id="first-install-opendmarc-from-the-repository" id="first-install-opendmarc-from-the-repository">First, install OpenDMARC from the repository.</h3>

<pre><code>apt update
apt install opendmarc -y
</code></pre>

<p>Verify that the user and group <code>opendmarc</code> has been created by checking <code>/etc/passw</code>d and <code>/etc/group</code>. Otherwhise, create them.
When you have installed it, verify the installation by running this:</p>

<pre><code>opendmarc -V
</code></pre>

<p>You will get something like this (the version number is not that important yet):</p>

<pre><code>opendmarc: OpenDMARC Filter v1.3.2       
    SMFI_VERSION 0x1000001       
    libmilter version 1.0.1       
    Active code options:               
    WITH_SPF               
    WITH_SPF2
</code></pre>

<p>Great! Let&#39;s proceed to configuring opendmarc
First, take a backup of the current opendmarc.conf, it will save some headache in the future if you want to redo it:</p>

<pre><code>cp /etc/opendmarc.conf /etc/opendmarc.conf.BAK
</code></pre>

<p>Edit /etc/opendmarc.conf with the following:</p>

<pre><code>AuthservID [SERVERHOSTNAME]
FailureReports true
PidFile /var/run/opendmarc.pid
RejectFailures false
SPFSelfValidate yes
Socket inet:8893@localhost
SoftwareHeader true
Syslog true
SyslogFacility mail
TrustedAuthservIDs [SERVERHOSTNAME]
HistoryFile /var/run/opendmarc/opendmarc.dat
UMask 0002
UserID opendmarc
</code></pre>

<p>Dont forget to restart opendmarc</p>

<pre><code>service opendmarc restart 
</code></pre>

<p>Proceed with adding opendmarc as a milter in postfix. I am assuming that you already have opendkim enabled as a milter like this:</p>

<pre><code>smtpd_milters = inet:localhost:8891
non_smtpd_milters = inet:localhost:8891
</code></pre>

<p>We now need to add the opendmarc milter into the postfix configuration, it is important that you add it AFTER the opendkim milter, otherwhise opendmarc will not be able to check if the DKIM key is valid.</p>

<pre><code>smtpd_milters = inet:localhost:8891,inet:localhost:8893
non_smtpd_milters = inet:localhost:8891,inet:localhost:8893
milter_default_action = accept
</code></pre>

<p>The last one is pretty important, so if one of your milters does not work for some reason – Postfix will still let it throu.
Restart postfix</p>

<pre><code>service postfix restart
</code></pre>

<p>We should now be able to test the configuration by sending an email from example a gmail.com account to an email address on your email-server and check your logs if opendmarc actually works.</p>

<pre><code>tail -f /var/log/mail.log | grep &#34;opendmarc&#34;
</code></pre>

<p>You should be able to see this:</p>

<pre><code>Apr 26 12:16:38 mx opendmarc[31490]: 5155751C32: SPF(mailfrom): dmarctest@linux.pizza pass
Apr 26 12:16:39 mx opendmarc[31490]: 5155751C32: linux.pizza pass
</code></pre>

<p>Great! Your server does now validate DMARC policies! If you just wanted this basic functionality, you are done now.
But there is always room for improvement!</p>

<h3 id="adding-a-public-suffix-list" id="adding-a-public-suffix-list">Adding a Public-suffix list</h3>

<p>This can be achieved in the following simple steps:
Create a catalogue (and change ownership) for the list to be downloaded to:</p>

<pre><code>mkdir -p /etc/opendmarc/
chown opendmarc: /etc/opendmarc
</code></pre>

<p>Set up a cronjob to download the suffix list once a week</p>

<pre><code>crontab -u opendmarc -e
</code></pre>

<p>And this line:</p>

<pre><code>@weekly/usr/bin/wget -k -q -N -P /etc/opendmarc https://publicsuffix.org/list/effective_tld_names.dat
</code></pre>

<p>Also, just download the list so you have it before you configure opendmarc to use it:</p>

<pre><code>wget -k -q -N -P /etc/opendmarc https://publicsuffix.org/list/effective_tld_names.dat 
</code></pre>

<p>Finally, configure opendmarc to actually use that list, put this on the bottom in /etc/opendmarc.conf and restart opendmarc</p>

<pre><code>PublicSuffixList /etc/opendmarc/effective_tld_names.dat
</code></pre>

<pre><code>service opendmarc restart 
</code></pre>

<p>Awesome! You are now done with the OpenDMARC.
Next up – adding DMARC reporting, this will be in an upcoming post.</p>

<p><a href="https://blogs.linux.pizza/tag:postfix" class="hashtag"><span>#</span><span class="p-category">postfix</span></a> <a href="https://blogs.linux.pizza/tag:dmarc" class="hashtag"><span>#</span><span class="p-category">dmarc</span></a> <a href="https://blogs.linux.pizza/tag:opendmarc" class="hashtag"><span>#</span><span class="p-category">opendmarc</span></a> <a href="https://blogs.linux.pizza/tag:smtp" class="hashtag"><span>#</span><span class="p-category">smtp</span></a> <a href="https://blogs.linux.pizza/tag:email" class="hashtag"><span>#</span><span class="p-category">email</span></a> <a href="https://blogs.linux.pizza/tag:linux" class="hashtag"><span>#</span><span class="p-category">linux</span></a></p>
]]></content:encoded>
      <guid>https://blogs.linux.pizza/deploying-opendmarc-on-your-postfix-mailserver</guid>
      <pubDate>Mon, 24 Jun 2019 17:14:08 +0000</pubDate>
    </item>
  </channel>
</rss>