Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

The postfix server puts sometimes mails in corrupt queue. These mails are never checked because there is an error in the file (I see "bad record type: 43 in message content"). In the documentation, I can see "Unreadable or damaged queue files are moved here for inspection".

OK. I can read them with postcat, but after that, what should I do ? Can I remove them without error ? What should I do to put them back in send queue ? I found somewhere to move the files to maildrop but nothing happens.

Thanks !

Dom

share|improve this question

3 Answers 3

up vote 7 down vote accepted

It's quite a strange behaviour, I've never seen postfix doing that, ever, you either have a very old postfix, or you must have some sort of hardware problem somewhere, like memory corruption or hard drive corruption.

To put back your email into the queue, the easiest way would be to do so with postcat and a bit of awk, something like (but YMMV) :

postcat -q <m-id>  |
awk 'BEGIN {data=0}
     /^*** HEADER EXTRACTED/ {data=0;print "."; print "quit"}
     data==1 {if ($0 == ".") { $0 = ".."}; print}
     /^*** MESSAGE CONTENTS/ {data=1; print "DATA"}
     data==0 && /^sender:/ {print "HELO myfqdn\nMAIL FROM: " $2}
     data==0 && /^original_recipient: / {print "RCPT TO: " $2}' |
sendmail -bs
share|improve this answer
    
Ok your script remove the postfix tags, and works well, but can I put the result in a queue to restart the distribution ? Is there an other way ? –  Dom Feb 2 '10 at 9:44
1  
I've completed the pipeline, it should be ok now. I don't see another way, but you really, really have a problem somewhere else, postfix does not creates bad files by itself. –  mat Feb 2 '10 at 10:00
    
Thanks it works perfectly ! –  Dom Feb 2 '10 at 11:54

I wound up with corrupted messages after manually editing errant messages with vim. To fix this I had to edit the files using a hex editor okteta. Briefly, the first line of the message contains 5 ascii values. The first and last values are the message length, the second value is the envelope length. Not sure about the other values.

Each record is preceded by a 1-byte record type, and a 1-byte record length. Both of these values are binary and need to be changed as necessary with a hex editor.

You can use various options on postcat to detect if there are any errors.

    postcat <msgid>
    postcat -b <msgid>
    postcat -e <msgid>
    postcat -v <msgid>

To resend the message, I had to add "HELO myfqdn\n" immediately prior to the "MAIL FROM:"

share|improve this answer

Can you provide a postfix version number? Which distribution is this?

(Still most likely this indicates a hardware problem.)

EDIT: then its filesystem corruption and/or memory problem. Try to run memtest.

share|improve this answer
    
On Debian Lenny, Postfix stable 2.5.5 –  Dom Feb 2 '10 at 9:34

Your Answer

 
discard

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.