{"id":5350,"date":"2020-01-29T22:59:49","date_gmt":"2020-01-29T17:29:49","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=5350"},"modified":"2026-11-08T15:25:08","modified_gmt":"2026-11-08T09:55:08","slug":"how-to-remove-the-entire-mail-queue-in-manual-way","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/how-to-remove-the-entire-mail-queue-in-manual-way\/","title":{"rendered":"How to Remove the Entire Mail Queue in a Manual Way"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Post Date:<\/strong> January 29, 2020<br><strong>Last Updated: <\/strong>November 08, 2026<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This guide explains how to remove the entire mail queue in Exim by resetting the spool directory manually. A stuck or spam-flooded queue can slow down a mail server and delay genuine emails. Clearing it by hand is the fastest fix, and it works on any Linux server running Exim, including cPanel\/WHM servers.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The original guide moved the spool folder and recreated it. That still works, but it skipped one important step: stopping Exim first. If Exim keeps running while you move the folder, it can write new messages into a spool that is being replaced. This version adds that step, plus a check to confirm the queue is empty.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Warning:<\/strong> When you remove the entire mail queue, every queued message is deleted, including legitimate ones. Keep the backup folder (<code>exim.old<\/code>) until you have confirmed everything works.<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before you remove the entire mail queue, make sure you have:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Root or sudo access to the server<\/li>\n\n\n\n<li>Exim installed and running (default spool path: <code>\/var\/spool\/exim<\/code>)<\/li>\n\n\n\n<li>A short maintenance window, because mail delivery pauses briefly<\/li>\n\n\n\n<li>The correct service name for your system (<code>exim<\/code>, or <code>exim4<\/code> on Debian and Ubuntu)<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Architecture<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Exim receives each email and stores it in the spool directory (<code>\/var\/spool\/exim<\/code>) until it is delivered<\/li>\n\n\n\n<li>The spool holds three folders: <code>input<\/code> for message headers and bodies, <code>msglog<\/code> for per-message delivery logs, and <code>db<\/code> for retry and hints databases<\/li>\n\n\n\n<li>The <code>mail<\/code> user must own the spool so Exim can read and write to it<\/li>\n\n\n\n<li><code>systemd<\/code> or <code>SysVinit<\/code> stops and starts Exim, so no new files are written during the reset<\/li>\n\n\n\n<li>To clear the queue, you stop Exim, rename the old spool as a backup, create a fresh empty spool, fix the ownership, and start Exim again<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The image below shows how the manual reset works. For queue-management options beyond this method, see the <a href=\"https:\/\/www.exim.org\/docs.html\" target=\"_blank\" rel=\"noopener\">official Exim documentation<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/01\/Manual-Exim-Mail-Queue-Removal-Guide.png\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"683\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/01\/Manual-Exim-Mail-Queue-Removal-Guide-1024x683.png\" alt=\"\" class=\"wp-image-13014\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/01\/Manual-Exim-Mail-Queue-Removal-Guide-1024x683.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/01\/Manual-Exim-Mail-Queue-Removal-Guide-300x200.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/01\/Manual-Exim-Mail-Queue-Removal-Guide-768x512.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/01\/Manual-Exim-Mail-Queue-Removal-Guide-272x182.png 272w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/01\/Manual-Exim-Mail-Queue-Removal-Guide.png 1536w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Steps to Remove the Entire Mail Queue<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Stop Exim<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Stopping Exim first prevents new messages from landing in the spool while you move it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For <code>systemd<\/code> systems:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">systemctl stop exim\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For <code>SysVinit<\/code> systems:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">service exim stop\n<\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> On Debian and Ubuntu, the service name is usually <code>exim4<\/code>. The <a href=\"https:\/\/www.freedesktop.org\/software\/systemd\/man\/latest\/systemctl.html\" target=\"_blank\" rel=\"noopener\">systemctl manual<\/a> explains the service commands.<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">2. Change Directory to the Spool<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cd \/var\/spool\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. Move the Old Exim Folder<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Renaming the folder is the quickest way to remove the entire mail queue while keeping a backup.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mv exim exim.old\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4. Create New Directories for input, msglog and db<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mkdir -p exim\/input\nmkdir -p exim\/msglog\nmkdir -p exim\/db\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">5. Set Ownership to mail<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">chown -R mail:mail exim\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">6. Start Exim and Verify<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">For <code>systemd<\/code> systems:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">systemctl start exim\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For <code>SysVinit<\/code> systems:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">service exim start\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then check that the queue is empty:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">exim -bpc\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A result of <code>0<\/code> means the queue is cleared. Once you are sure no messages need recovery, delete the backup:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">rm -rf \/var\/spool\/exim.old\n<\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> To delete only specific messages instead of the whole queue, list them with <code>exim -bp<\/code> and remove one with <code>exim -Mrm &lt;message-id&gt;<\/code>.<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If the queue is not cleared or Exim will not start, check these:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Exim fails to start:<\/strong> Confirm ownership with <code>ls -ld \/var\/spool\/exim<\/code> and repeat Step 5. Check the log at <code>\/var\/log\/exim_mainlog<\/code> (cPanel\/RHEL) or <code>\/var\/log\/exim4\/mainlog<\/code> (Debian)<\/li>\n\n\n\n<li><strong>Queue still shows messages:<\/strong> Exim was probably still running during the move. Stop it fully, repeat the steps, and run <code>exim -bpc<\/code> again<\/li>\n\n\n\n<li><strong>Permission or SELinux errors:<\/strong> On SELinux systems, run <code>restorecon -R \/var\/spool\/exim<\/code><\/li>\n\n\n\n<li><strong>You need the old messages back:<\/strong> Stop Exim, remove the new <code>exim<\/code> folder, and rename <code>exim.old<\/code> back to <code>exim<\/code><\/li>\n\n\n\n<li><strong>Debian or Ubuntu:<\/strong> The spool path is usually <code>\/var\/spool\/exim4<\/code> and the owner is <code>Debian-exim<\/code>, so adjust the commands<\/li>\n\n\n\n<li><strong>You want to remove the entire mail queue without downtime:<\/strong> This is not possible with this method, because Exim must be stopped. Use <code>exim -Mrm &lt;message-id&gt;<\/code> to delete individual messages instead.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Resetting the spool folder is a fast, reliable way to remove the entire mail queue when it is clogged with spam or undeliverable mail. Stop Exim, rename the spool, recreate the three folders, fix the ownership, and start the service again. Keep the <code>exim.old<\/code> backup until you have confirmed that the server is delivering mail normally.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently Asked Questions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Is it safe to remove the entire mail queue?<\/strong><br>Yes, but every queued message is lost, including legitimate emails. Keep <code>exim.old<\/code> as a backup until you are sure.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Do I need to stop Exim first?<\/strong><br>Yes. Stopping it prevents new files from being written to the spool while you move it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>How do I check how many messages are in the queue?<\/strong><br>Run <code>exim -bpc<\/code> for a count, or <code>exim -bp<\/code> for a full list.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Can I delete only the spam messages?<\/strong><br>Yes. Remove individual messages with <code>exim -Mrm &lt;message-id&gt;<\/code> instead of resetting the whole spool.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related Articles<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After you remove the entire mail queue, these guides cover more Exim commands and ways to test mail delivery.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/exim-mail-server-commands\/\" target=\"_blank\" rel=\"noreferrer noopener\">Exim mail server \u2013 commands<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/send-an-email-using-telnet-from-remote-servers\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Send an Email Using Telnet from a Remote Server<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Talk to Our Technology Experts<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Dealing with a clogged mail queue or Exim delivery problems? Our team can help with mail server configuration, spam control, and ongoing monitoring through our <a href=\"https:\/\/pheonixsolutions.com\/software-maintenance-and-support\/\">Software Maintenance and Support<\/a> services.<br><br><a href=\"https:\/\/pheonixsolutions.com\/contact\">Connect with our technology experts<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Post Date: January 29, 2020Last Updated: November 08, 2026 Introduction This guide explains how to remove the entire mail queue [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":13013,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1019],"tags":[747,746],"class_list":["post-5350","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cloud-aws","tag-manually-remove-mail-queue","tag-remove-mail-queue","psol-cat-cloud-aws"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-1oi","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/01\/Exim-Mail-Queue-Cleanup-Guide.png","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/5350","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=5350"}],"version-history":[{"count":8,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/5350\/revisions"}],"predecessor-version":[{"id":13041,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/5350\/revisions\/13041"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media\/13013"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=5350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=5350"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=5350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}