mail stuck in queue, can it be modified

keat63

Well-Known Member
Nov 20, 2014
1,387
108
93
cPanel Access Level
Root Administrator
We have an automated system which sends out customer invoices.
Occasionally, our end users may have inputted the customers email address into the automated system incorrectly.
On such occasions, the invoice will get stuck in the mail queue until it falls off the end.

Is it possible for me to correct these typos whilst the mail is stuck in the queue.

I don't see anything in whm or mailscanner that will allow me to do this.
 

sparek-3

Well-Known Member
Aug 10, 2002
1,929
178
343
cPanel Access Level
Root Administrator
(Not for the faint of heart)

If the message is stuck in the queue you can try modifying the files directly at:

/var/spool/exim/input/%alphanumeric%/%messageid%-D
/var/spool/exim/input/%alphanumeric%/%messageid%-H


You will need to know the message ID of the specific message, and probably the easiest way to find these files is to use grep:

grep -lr %messageid% /var/spool/exim/input

The -H file is referring to the headers of the message.

The -D file is referring to the message contents or body.

(The %alphanumeric% code is going to be the last alphanumeric character before the first dash in the message id)

I cannot vouch for this method and I don't really recommend it. But it would seem to be possible to do. Although I think there may be a checksum some where in this, so the message knows how big it's suppose to be. This means you can't remove 1 character and add 2 characters. It has to be a 1:1 change. Although I'm not entirely sure if that's correct.
 
  • Like
Reactions: cPanelLauren

cPanelLauren

Forums Analyst II
Staff member
Nov 14, 2017
8,110
659
263
Houston
cPanel Access Level
DataCenter Provider
I tested the method mentioned by @sparek-3 on my own server and found that it does indeed work. I modified the header of a message stuck in queue to change the recipient address. I should also point out that this method is not something that is supported by cPanel but I do hope it answers your question.

I did

Code:
grep -r MessageID /var/spool/exim/input
to find the message and used vi to modify the header portion.

Thanks!
 

keat63

Well-Known Member
Nov 20, 2014
1,387
108
93
cPanel Access Level
Root Administrator
I also tried this and it appeared to work.
In my case the email address was missing a letter from the domain name, I added the missing letter and the mail went from the queue.
So when I say it worked, it's no longer stuck in the queue, so I assume it did, however, i don't see it in mailscanner.

I found the message ID from the mail queue, so no need to grep.

I have CSF explorer installed, so it was pretty easy to not only navigate and identify the header, but also modify and save it.
This is one that I will have to test a little more and document for future.
 
Last edited: