Posts Tagged ‘postfix’
Manage the postfix mailqueue with postsuper, postqueue und mailq
Postfix provides with postsuper, postqueue and mailq some shell utilitys to manage the mailqueue.
Here are some examples for common tasks:
List all messages that are in the mailqueue
postqueue -p
The output looks like this:
root@server:/# postqueue -p -Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient------- 501CA23B43DB 2182 Thu Dec 3 14:24:39 test@yourdomain.com (Host or domain name not found. Name service error for name=otherdomain.com type=MX: Host not found, try again) info@otherdomain.com -- 8 Kbytes in 1 Requests. <strong>Delete a message by message ID</strong> <p class="command">postsuper -d MessageID
replace MessageID with the ID of the message, e.g. 501CA23B43DB
root@server:/# postsuper -d 501CA23B43DB postsuper: 501CA23B43DB: removed postsuper: Deleted: 1 message <strong>Remove emails by sender</strong> <p class="command">mailq | tail +2 | awk 'BEGIN { RS = "" } # $7=sender, $8=recipient1, $9=recipient2 { if ($7 == "info@otherdomain.com" && $9 == "") print $1 } ' | tr -d '*!' | postsuper -d - replace "info@otherdomain.com" with the sender email address. <strong>Remove emails by recipient</strong> <p class="command">mailq | tail +2 | awk 'BEGIN { RS = "" } # $7=sender, $8=recipient1, $9=recipient2 { if ($8 == "you@yourdomain.com" && $9 == "") print $1 } ' | tr -d '*!' | postsuper -d - replace you@yourdomain.com with the recipient email address. <strong>Remove emails by sender hostname</strong> <p class="command">mailq | grep senderhostname | awk ‘{ print $1′} | postsuper -d -
replace the word “senderhostname” with the hostname of the email sender.
If your server has very high load and you want to temporarily move all message from the incoming queue to the hold queue, use the command:
postsuper -h ALL
to move the messages back to the incoming queue, use the command:
postsuper -r ALL
Instead of the word “ALL” you can also provide a specific message ID to move only one message to or from the hold queue. Message in the hold queue will not processed by postfix until they were requeued with postsuper -r.
How to enable port 465 (smtps) in postfix mailserver
More and more internet access providers are closing port 25 to reduce spam except for connections to their own mailservers. If you run your own mailserver and have problems to connect to it on port 25, you can enable port 465 (smtps) in postfix as a workaround. Edit the /etc/postfix/master.cf file:
vi /etc/postfix/master.cf
and remove the # in front of the smtps line. Example for Debain 5, change the line:
#smtps inet n - - - - smtpd
to:
smtps inet n - - - - smtpd
and restart postfix:
/etc/init.d/postfix restart
Install postfix with MySQL support on CentOS 5.3 (64Bit)
The following article explains the steps to compile postfix MTA with MySQL support on CentOS 5.3 as e.g. needed for ISPConfig 3.
Remove the postfix package from CentOS which does not has MySQL support:
/etc/init.d/postfix stop rpm -e --nodeps postfix Download the postfix source RPM and install it: <p class="command">cd /tmp wget http://mirror.rackspace.com/CentOS/5.3/os/SRPMS/postfix-2.3.3-2.1.el5_2.src.rpm rpm -i postfix-2.3.3-2.1.el5_2.src.rpm Edit the spec file to enable MySQL support. <p class="command">vi /usr/src/redhat/SPECS/postfix.spec
and change the line:
%define MYSQL 0
to:
%define MYSQL 1
Install a few prerequisites before we build the new postfix RPM package
yum install pcre-devel mysql-devel
Build the postfix RPM with MySQL support:
rpmbuild -ba /usr/src/redhat/SPECS/postfix.spec
and install it.
cd /usr/src/redhat/RPMS/x86_64
rpm -i postfix-2.3.3-2.1.x86_64.rpm
Start postfix and configure it to be started at boot time:
/etc/init.d/postfix start
chkconfig –levels 235 postfix on
Postfix: “queue file write error”
If you get an error like:
Aug 21 12:41:03 webb4 postfix/sendmail[11234]: fatal: web1_user(12967): queue file write error
in your mail log, then the vale for message_size_limit in postfix main.cf is too low. Edit postfix main.cf:
vi /etc/postfix/main.cf
and set the message size limit to a higher value. E.g.
mesage_size_limit = 900000000
and restart postfix:
/etc/init.d/postfix restart
If there is no message_size_limit set in main.cf, just add the line.