LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Fetchmail and Imap Issue (https://www.linuxquestions.org/questions/linux-server-73/fetchmail-and-imap-issue-742677/)

darkeagl 07-25-2009 04:29 AM

Fetchmail and Imap Issue
 
Hi guys,

Till now I could solve all my problems with your help in the forum but now I cannot find anything really that helps me so I ask directly.

I set up a new Suse 11.1 server with fetchmail postfix and cyrus. The problem was that I started fetchmail for the first try without configuring postfix and cyrus first.
Now the problem: I have in /var/spool/mail couple of large files with several mails in them. How can I separate them and deliver them to my /var/spool/imap/user ... folders? I donīt want to do it manually and there should be an easier way, I hope.

I hope for a fast answer :) And thank you guys anyways.

unSpawn 07-26-2009 06:08 AM

Configure procmail with the right delivery recipes, then cat the mailspools and pipe them through procmail?

darkeagl 07-26-2009 01:43 PM

I have already set up the system without procmail. After a long search yesterday I found a nice small script mb2md which did the trick now I just need to import the mails somehow to the imap cyrus system.

unSpawn 07-26-2009 05:35 PM

IMAP is just a representation layer on top of the mailbox and maildir format.

darkeagl 07-27-2009 05:51 AM

OK but how do I import my mails now into the maildir system, that cyrus and the users see them? Iīm totally new to this kind of stuff and frustrated right now. Sitting on this small thing now already for a week...

unSpawn 07-27-2009 06:40 AM

I pointed to procmail but in return you said you "already set up the system without procmail" and something about some script. That makes it kind of stalemate, right?
So as far as your options go you could 0) install procmail, 1) wait for somebody to recommend Something Else, 2) go search for another solution or 3) move emails manually.

darkeagl 07-28-2009 05:02 AM

I could install procmail, or better to say it is installed but I just donīt use it. Can you tell me step by step how to do it on Suse 11.1. I would appreciate it.

unSpawn 07-28-2009 07:31 AM

Simply put procmail is a mail delivery agent (MDA). It gets handed over complete messages from a mail transfer agent (MTA) and delivers those according to rules. Note the input usually comes from the MTA but can be a another process, a mailbox or maildir as well as any other convoluted scheme. Also note "delivery" means stuffing messages in local mailboxes or maildirs but any preprocessing like handing it off to an AV scanner, changing subject or driving arbitrary scripts is possible. Because procmail can see the whole message these rules (called "recipes") can act on any aspect of a message including headers that are invisible to the mail user agent (MUA), visible headers like the sender, lists of addresses, recipient, subject and whatnot.

* In general experimenting can lead to interesting results and mucking with mailspools and procmail isn't the exception. Working with copies of mailspools, delivering to test addresses and using test mailboxes makes sense. Also enable debug settings.

Let's try delivering email messages from a copy mailspool to a local users test maildirs:
Code:

PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin
SHELL=/bin/sh
# "VERBOSE=on" for debugging.
VERBOSE=on
# Default delivery option
DROPPRIVS=yes
# As much logging as possible
LOGABSTRACT=all
# Mailbox to deliver to if not filtered
DEFAULT=/var/TEST/procmail.mbx
# Logfile to read back in case of troubleshooting
LOGFILE=/var/TEST/procmail.log

# Deliver to MAILDIR (notice slash at end of path) for recipient "postmaster"
:0:
* ^To:.*postmaster
/var/TEST/spool/imap/postmaster/MAILDIR/

# Deliver to MAILDIR for recipient "Administrator" who can be in the
# "hostname.doma.in", "doma.in" or "localhost" domain:
:0:
* ^To:.*Administrator@(([-a-z0-9]+\.)*doma\.in|localhost)
/var/TEST/spool/imap/administrator/MAILDIR/

# =========================================================================
# Last rule:  mailbox for unfiltered email
:0:
$DEFAULT
# ==========================================================================
# End of Recipes

How to use this. In /var/TEST/spool/ create "${USERNAME}/MAILDIR/" subdirectories for all usernames you want to test delivery with and set user access accordingly. Save above recipe as /var/TEST/procmail.rc and create a recipe for each user you created a test maildir for. Run ''cat /var/spool/mail/spoolfilename | formail -s | procmail -m /var/TEST/procmail.rc 2>&1 | tee /var/TEST/procmail.tee'. Read back /var/TEST/procmail.log in case of errors and check /var/TEST/procmail.mbx for undeliverables.


All times are GMT -5. The time now is 06:14 PM.