# Problems with procmail/postfix mails get returned!

## onkelfusspilz

Hi,

I use Postfix with Fetchmail and it works nice. Now I want to get my mail sorted into folders automatically, so I emerged procmail.

Procmail sorted the mails into the folders, but not in /root/.maildir/cur as it should, or /root/.maildir/.newsletters/cur, the mails are placed one level up, like /root/.maildir or /root/.maildir/.newsletters so I can't get access to the mails with the courier-imap server. I tried to use MSGPREFIX=cur/ and it worked! But now, everytime I send a mail to my server, the mail is rejected with a answer from the "Mail Delivery Subsyste" with a message like this: 

```

 ...<root@xyz.org>: can't create user output file. Command output:

<root@xyz.org>: can't create user output file. Command output:

    procmail: [5106] Wed May 14 22:41:11 2003 procmail: Assigning

    "MSGPREFIX=cur/" procmail: Assigning "LOGFILE=/root/.maildir/log" procmail:

    Opening "/root/.maildir/log" procmail: Unknown user "-a" procmail: Unknown

    user "" procmail: [5105] Wed May 14 22:41:11 2003 procmail: Assigning

    "MSGPREFIX=cur/" procmail: Assigning "LOGFILE=/root/.maildir/log" procmail:

    Opening "/root/.maildir/log"

```

But the mail is in the right place and I can see the mail in evolution over imap!

Here are some details about my system. I call procmail from /etc/postfix/main.cf with 

```
 mailbox_command = /usr/bin/procmail -d "$LOGNAME" -a "$EXTENSION" "$USER"
```

and my /root/.processmailrc looks like this

```

MAILDIR=$HOME/.maildir

VERBOSE=yes

MSGPREFIX=cur/

LOGFILE=$MAILDIR/log

:0:

* ^From:.*root@xyz.org

.root

```

Does anyone have a idea what the hell is wrong here?

Thank you for your help!

----------

## psp

Hmmm... not too sure about this. I use postfix and procmail, but I use postfix to do the delivery of mail (I don't set a system wide mailbox command).  I use a .forward file to pipe mail to procmail. No CUR hacks required.

I don't know whether you want to move to this system, but it's the one that works for me.

Hope this helps.

----------

## onkelfusspilz

Hi psp,

I just want to use the function of procmail to sort mails in different folders, so it seems to me like the easiest way is to activate procmail as mail delivery agent.

 *Quote:*   

>  I use a .forward file to pipe mail to procmail. No CUR hacks required. 

 

This sounds ok for me, please can you tell me how you've formatted your .forward to let procmail sort the mails for you?

Thanks

----------

## TM001

Hi,

Im using practically the same setup. Try adding slashes at the end of paths in your .procmailrc file, something like this:

```

SHELL=/bin/sh               #Shell used to run procmail. 

LINEBUF=4096                #Needed to keep Procmail from choking on long

                            #"recipes", or instructions on what to do with

                            #particular kinds of email.

PATH=$HOME/bin:/bin:/usr/bin:/usr/local/bin:

                            #Path for your programs 

VERBOSE=on                 #Change this to "on" when you try a new recipe

                            #so that Procmail will log literally every step

                            #it takes.  DO NOT LEAVE IT ON, though, because

                            #it creates huge logfiles.

# Default Program & file locations

MAILDIR=$HOME/.maildir/          #you'd better make sure this directory exists

DEFAULT=$HOME/.maildir/         #default incoming mailbox 

LOGFILE=$MAILDIR/procmail.log #Logs message disposition.  Recommended -- otherwise

                            #errors are emailed to you. :/

FORMAIL=/usr/bin/formail        #useful for autoreply recipes.

SENDMAIL=/usr/sbin/sendmail    #useful for autoreply recipes.  

:0:

* ^From.*gentoo

$HOME/.maildir/.Gentoo/

```

----------

## onkelfusspilz

Thank you for your help, but this was not the trick  :Sad: 

I've played around with some parameters and now there are no delivery-error messages anymore. I've cutted off the mailbox_command from "-a ...." on and my mail delivery is ok now.

But I need the MSGPREFIX set to "cur/" to geht procmail delivering into the home/user/.maildir/cur/ directory and I don't know if this is what the MSGPREFIX var is for  :Wink: 

But I have another nice error now! Maildelivering is ok, if I DON'T modify the mail with procmail. If I do, the mail is delivered to the right folder, but it is corrupted! This is the rule I use for testing:

```

:0:

* ^From:.*user@mydomain.org

.testfolder

```

If the rule matches, my mail is delivered in the testfolder, but it is corrupted. Squirrelmail shows up a Mail without sender name or anything else and if I try to open the mail I get a

```
 

ERROR Yeah I know, not a very usefull errormessage (id = 0, mailbox = INBOX.testfolder sqimap_get_message)

```

...original message  :Wink: 

Other IMAP clients don't show any messages or the message is gone after I click on it.

I thought this would be a small nut with procmail but it finished with a nightmare!

Someone to help out?

Thanks!

----------

## psp

Sorry I took so long... I hope you are "watching" this thread.

I have no mailbox_command setup in postfix and a .forward file in my home directory.

This is my postfix setup (main.cf):

```
root@myhost# postconf | grep mailbox_command

mailbox_command = 

mailbox_command_maps = 
```

This is a 'cat' of my /home/psp/.forward file:

```
# This is from the procmail man page:

"|IFS=' ' && p=/usr/bin/procmail && test -f $p && exec $p -Yf- || exit 75 #psp"
```

This is a sample 'cat' of my /home/psp/.procmailrc file:

```
# $Id: .procmailrc ,v 1.2 2003/01/21 09:16:37 cvs Exp $

MAILDIR=/home/psp/.maildir

LOGFILE=/home/psp/.logs/procmail.log

##-- ARCHIVE MAIL

##----------------------------------------------------------------------------#

:0 c

archive/

# etc. etc. etc.
```

Hope this helps...

----------

## onkelfusspilz

Thank you very much,

I have't understand your .forward command completely, it seems to make 4 operations, but what is IFS? But I trust you that it ist not a virus  :Wink: 

but it does'nt change anything. Procmail works, as it does before, but my mails get unreadable if moved to another folder by procmail. As long as no procmail rules matches, my mail delivery is ok.

I'll try another procmail version and go on testing ...

Thank you for your help!

----------

## onkelfusspilz

I took a look at one of the files that were corrupted and I found out, that the only change procmail made to the file were 2 lines at the top!

Procmail added these lines:

 *Quote:*   

> From me@me.domain.org  Fri May 16 20:34:25 2003
> 
> >From me Fri May 16 20:34:25 2003

 

But these lines prevent my mailclients from successfully reading my mailfiles.

What the hell can force procmail to doo this silly stuff !?!

Any ideas?

Thanks!

----------

