<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.zhouba.cz/index.php?action=history&amp;feed=atom&amp;title=ZhoubaWiki%3APostfixTips</id>
	<title>ZhoubaWiki:PostfixTips - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.zhouba.cz/index.php?action=history&amp;feed=atom&amp;title=ZhoubaWiki%3APostfixTips"/>
	<link rel="alternate" type="text/html" href="https://wiki.zhouba.cz/index.php?title=ZhoubaWiki:PostfixTips&amp;action=history"/>
	<updated>2026-04-04T06:55:36Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.2</generator>
	<entry>
		<id>https://wiki.zhouba.cz/index.php?title=ZhoubaWiki:PostfixTips&amp;diff=14&amp;oldid=prev</id>
		<title>Garak: Created page with &quot;This page contain some usefull commands and tips for using Postfix.  = Certificate problems =  If postfix can't validate email certificiates mail log will be full of message l...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.zhouba.cz/index.php?title=ZhoubaWiki:PostfixTips&amp;diff=14&amp;oldid=prev"/>
		<updated>2021-05-22T16:22:25Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;This page contain some usefull commands and tips for using Postfix.  = Certificate problems =  If postfix can&amp;#039;t validate email certificiates mail log will be full of message l...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This page contain some usefull commands and tips for using Postfix.&lt;br /&gt;
&lt;br /&gt;
= Certificate problems =&lt;br /&gt;
&lt;br /&gt;
If postfix can't validate email certificiates mail log will be full of message like these&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
certificate verification failed for gmail-smtp-in.l.google.com[74.125.196.26]:25: untrusted issuer /C=US/O=Equifax/OU=Equifax Secure Certificate Authority&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Check if certificates are installed and updated in &amp;lt;code&amp;gt;/etc/ssl/certs/&amp;lt;/code&amp;gt;, if they are set&lt;br /&gt;
path to them manually by adding line to &amp;lt;code&amp;gt;/etc/postfix/main.cf&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Checking mail queue =&lt;br /&gt;
To check current mail queue use:&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
postqueue -p | tail -n 1 | cut -d' ' -f5&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Searching and restoring emails in SPAM folder =&lt;br /&gt;
Default spam folder is &amp;lt;code bash&amp;gt;/var/lib/amavis/virusmails&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To find name of spam email containing KEYWORD:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /var/lib/amavis/virusmails&lt;br /&gt;
find . -name &amp;quot;*spam*.gz&amp;quot; -exec zgrep -l 'KEYWORD' {} \;| cut -c 3-&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To copy spam to original recipient mailbox, EMAILNAME should be relative to spam folder.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
amavisd-release EMAILNAME&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To release found mail:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
find . -name &amp;quot;*spam*.gz&amp;quot; -exec zgrep -l 'KEYWORD' {} \;| cut -c 3- | xargs -L 1 amavisd-release&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= How to move Postfix mail queue =&lt;br /&gt;
&lt;br /&gt;
This document describes how to move Postfix mail queue from one server to another without downtime.&lt;br /&gt;
&lt;br /&gt;
* '''ServerA''' - server with queue we want to move&lt;br /&gt;
* '''ServerB''' - server with install working Postfix&lt;br /&gt;
&lt;br /&gt;
Before start, check both ServerA and ServerB hold queue &amp;lt;code&amp;gt;/var/spool/postfix/hold&amp;lt;/code&amp;gt;.&lt;br /&gt;
Any email in hold queue will be send. In case there are emails in hold that should not be send move them out of hold folder.&lt;br /&gt;
&lt;br /&gt;
== ServerA ==&lt;br /&gt;
Move all waiting emails to hold queue.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
postsuper -h ALL&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tar hold folder and copy it to ServerB.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
tar -zcvf postfixhold.tar.gz /var/spool/postfix/hold&lt;br /&gt;
scp postfixhold.tar.gz user@ServerB:/home/user/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ServerB ==&lt;br /&gt;
Untar to &amp;lt;code&amp;gt;/var/spool/postfix/hold&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
tar -C / -zxvf postfixhold.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Number of added hold emails should increase queued emails (Protip: run this command before untaring hold emails)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
postqueue -p | tail -n 1 | cut -d' ' -f5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put emails from hold to deferred queue.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
postsuper -H ALL&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Manual recommends releasing emails near maximal wait time directly to active queue.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
postsuper -r ALL hold&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ServerA ==&lt;br /&gt;
Now remove whole hold queue on ServerA.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
postsuper -d ALL hold&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Log statistics =&lt;br /&gt;
&lt;br /&gt;
One of tools for generating statistics from email logs is &amp;lt;code&amp;gt;Pflogsumm&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Installation&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo curl -O http://jimsun.linxnet.com/downloads/pflogsumm-1.1.3.tar.gz&lt;br /&gt;
sudo tar -xzf pflogsumm-1.1.3.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./pflogsumm.pl /var/log/email.log &amp;gt; report.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Getting message id =&lt;br /&gt;
Getting message id from mail where argo or bugweis is mentioned&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mailq | grep -v '^ *(' | awk 'BEGIN { RS = &amp;quot;&amp;quot; } { if ($0 ~ /(argo22\.)|(bugweis\.)/) print $1 }' | tr -d '*!'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Release multiple emails from hold =&lt;br /&gt;
Can be connected wtih 'Getting message id' command and output piped directly to postsuer.&lt;br /&gt;
-H - will read message ID from input.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat ouremails_ID.txt | postsuper -H -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Removing emails for whole domain =&lt;br /&gt;
First be sure you know what are you doing, this will DELETE most of emails in standard email directory!&lt;br /&gt;
Running script at wrong place can cripple the company!&lt;br /&gt;
&lt;br /&gt;
Backup vhole email directory (/var/vmail/DOMAIN/).&lt;br /&gt;
&lt;br /&gt;
Run following script, make sure initial change directory is set correctly&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /var/vmail/DOMAIN;&lt;br /&gt;
for DIR in `ls -l`; do rm -vf $DIR/Maildir/cur/*;rm -vf $DIR/Maildir/new/*;rm -vf $DIR/Maildir/.*/cur/*;rm -vf $DIR/Maildir/.*/new/*; done;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Garak</name></author>
	</entry>
</feed>