Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have exim4 set up on Debian as a smarthost to send mail via Google's mail servers. We use Google Apps for everything else, so this made sense. Problem is, the password for the smart host account was changed, causing exim to bounce the messages back and then freeze them. Now I have a large collection of unsent mail in /var/spool/exim4/[input|msglog].

I have tried running:

exim -d -M 1Mx6IS-0006bC-3h

but that causes the bounced message to be sent, not the original. I can see a copy of the original message in /var/spool/exim4/input/1Mx6IS-0006bC-3h-D under the line

------ This is a copy of the message, including all the headers. ------

...but I have not figured out a way to take this frozen bounced message, and convert it back to the original message so it can be retried.

Any ideas?

share|improve this question
up vote 0 down vote accepted


This is a python script that should do what you want. It is thoroughly untested, and is guarenteed not to work in all cases. If you don't know Python, then nevermind, it was a nice bit of practice for me.

import os
import smtplib
import email

mydir ="/mydir")
server = smtplib.SMTP()

files = [mydir + "/" + f for f in os.listdir(mydir) if os.path.isfile(mydir + "/" + f)]

while files:
    f = files.pop()
    msg = email.message_from_file(open(f))
    body = msg.get_payload().split("------ This is a copy of the message, including all the headers. ------")[1].strip()    
    from_addr = msg["To"]
    to_addr = msg["X-Failed-Recipients"]
    print "Sending message to ", to_addr
    server.send(from_addr, to_addr, body)
    print "Message sent"
share|improve this answer
Thanks... that is actually what I ended up doing, but in BASH – Peter Sankauskas Oct 21 '09 at 16:04

Is this a final bounce? Or the one that says that another attempt to deliver will happen in some number of hours, if later, could it be that both messages are sent out, the original and bounce? Since both are in the queue, as I understand it from your question.

share|improve this answer
Yes it is a final bounce. Only a manual process of converting bounced message or extracting the original message from the bounce will work. – Peter Sankauskas Oct 13 '09 at 21:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.