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.

I have this code in /etc/procmailrc:

DROPPRIVS=yes

DEFAULT=$HOME/Maildir/

:0
* ? /usr/bin/test -d $DEFAULT || /bin/mkdir $DEFAULT
{ }
:0 E
{
        # Bail out if directory could not be created
        EXITCODE=127
        HOST=bail.out
}

MAILDIR=$HOME/Maildir/

But, when the directory already exists, sometimes it will send a return email with this error: 554 5.3.0 unknown mailer error 127. The email still gets delivered, mind you, but it sends back an error code to the sending user as well.

I fixed this temporarily by commenting out the EXITCODE and HOST lines, but I'd like to know if there is a better solution.

I found this block of code in multiple places across the net, but couldn't really find why this error was coming back to me. It seems to happen when I send an email to a local user. Sometimes the user has a .forward file to send it on to other users, sometimes not, but the result has been the same. I also tried removing DROPPRIVS, just in case it was messing up the forwarding, but it did not seem to affect it.

  • Is the line starting with * ? /usr/bin/test a problem?
  • The * signifies a regex, but the ? makes it return an integer value, correct?
  • What is the integer being matched against? Or is it just comparing the integer return value?
  • Do I need a space between the two blocks?

Thanks for the help.

share|improve this question

2 Answers 2

I'd bet on some kind of race condition. Does it matter if you wrap up the /usr/bin/test line into a little shell script? like:

* ? /usr/local/bin/make-sure-exists-dir $DEFAULT

with a make-sure-exists-dir that does:

/usr/bin/test -d "$1" || mkdir "$1"

also, in looking at the manpage for mkdir, -p doesn't error on existence, so you could just do:

* ? mkdir -p $DEFAULT
share|improve this answer
    
Good thinking, but it's been a while, so I'll need to put this back on my todo list. If I get a chance to try it out, I will accept it if your answer comes back to be right. –  bradlis7 May 3 '10 at 20:43
up vote 0 down vote accepted

Actually the dovecot instructions for procmail is what I was looking for.

# file: /etc/procmailrc
# system-wide settings for procmail
SHELL="/bin/bash"
SENDMAIL="/usr/sbin/sendmail -oi -t"
LOGFILE="/var/log/procmail.log"
DROPPRIVS="yes"
DELIVER="/usr/lib/dovecot/deliver"
# fallback:
DEFAULT="$HOME/Maildir/"
MAILDIR="$HOME/Maildir/"
:0 w
* ^X-Spam-Status: Yes
| $DELIVER -m spam
:0 w
| $DELIVER

Thanks for the assistance.

share|improve this answer

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.