1

Topic: Clear mail queue of failed emails

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release):
- Deployed with iRedMail Easy or the downloadable installer?
- Linux/BSD distribution name and version:
- Store mail accounts in which backend (LDAP/MySQL/PGSQL):
- Web server (Apache or Nginx):
- Manage mail accounts with iRedAdmin-Pro?
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

Wanted to clear mail queue of failed emails, kindly assist how to setup using cron job.

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Clear mail queue of failed emails

rukraj.pereira wrote:

Wanted to clear mail queue of failed emails, kindly assist how to setup using cron job.

postsuper-d ALL

3

Re: Clear mail queue of failed emails

thank you for the command.

we tried to create cron job using above command but its not working.

Kindly assist.

4

Re: Clear mail queue of failed emails

0 3 * * * root sh /home/scripts/clear-mail-queue.sh

5

Re: Clear mail queue of failed emails

That command doesn't clear failed mails, instead it deletes all mails which are in the mail queue

you can show them with command

mailq

This includes mails which were hold back due to greylisting for example, or which simply haven't been processed

running this command unattended is malcious and strongly unrecommended

if you have many failed mails, you better should check the reasons behind this

6

Re: Clear mail queue of failed emails

We have checked failed mail reason and most of email failed due to storage quota full and due to which mailq count is increasing.

Kindly advise how to clear using cron job.

7

Re: Clear mail queue of failed emails

Kindly suggest.

8

Re: Clear mail queue of failed emails

Use "postsuper" command to remove email in Postfix queue.
You need to do some scripting to find failed emails first, then call postsuper to remove them.
Removing all with 'postsuper -d ALL' is dangerous, because it removes all queued emails, not just failed ones.