LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices

Reply
 
Search this Thread
Old 10-30-2006, 04:57 PM   #1
wadesmart
Member
 
Registered: Jul 2005
Location: Oklahoma
Distribution: Ubuntu
Posts: 72

Rep: Reputation: 15
mbox to maildir help


10302006 1656 GMT-6

I just set up ubuntu 6.06LTS. I wanted to move away from my mbox mail setup as several crashes have left me unsettled. I have a desktop system and download my mail, viewing with Evolution.

I found this script mb2md to convert mbox to maildirs, but Im not very sure of what Im doing, even after reading the documentation.

As I understand it:

Code:
mb2md -s /home/user/.evolution/mail/local -R -d /home/user/Maildir
would go through and convert all my mail.

I want to convert my Inbox, Sent mail, and all my sub-folders as well.

wade
 
Old 10-30-2006, 05:05 PM   #2
chakkerz
Member
 
Registered: Dec 2002
Location: Brisbane, Australia
Distribution: RedHat (RHEL, FC, CentOS), openSuSE, Mac OS X
Posts: 653

Rep: Reputation: 32
Take a look at this: http://qmail.glasswings.com.au/top.html#maildir

When i moved from iMail (yuk) to postfix + courier imap i had this issue as well (though for a few thousand people).

I used that script i do not recall writing though it clearly is written by me (alas it has been 2 years). Looking at it, it appears to be total overkill for what you want to do, but verifies that your syntax is correct (though i did not use the -R). Maybe it helps:

Quote:
#!/bin/sh

# This script assumes:
# - the mailboxfile name (without extension) is the user name ** CHANGE:
# -> the files will be copied to a location (assume /home/chakkerz/__domain__/users/__usernames__)
# -> the scrip will be run in /home/chakkerz/__domain__ BUT this will be certified using pwd
# -> username will be the directory name
# -> the mailbox to be converted is named main.mbx
# -> any other mbx file presence should be noted to the error stream AND copied the the NEW maildir created for the user
# - the destination Maildir is in /var/spool/virtual

basedir=`pwd`
maildirdestination=/var/spool/mail/virtual/

mailboxfile=main.mbx
mailboxnewfile=new_main.mbx
mailboxtempfile=temp_main.mbx

# user=`echo mailboxfile | cut -d . -f1`

for user in `ls -F | grep "/" | cut -d / -f1`
do
echo "Processing $user"

# first create a maildir
# generate maildir path
maildirpath=$maildirdestination$1_$user
echo "Destination $maildirpath"

# ... then actually create the maildir
# echo "Create maildir"
# maildirmake++ $maildirpath

# anounce
echo from $mailboxfile via $mailboxtempfile to $mailboxnewfile
# add newline
cat $user/$mailboxfile | sed 's/From /\nFrom /g' > $mailboxtempfile
# remove the erroneously added newline to the FIRST line of the file - establish how many lines there are
linecount=`wc -l $mailboxtempfile | cut -d " " -f1`
# subtract one
linecount_wanted=`bc_wrapper $linecount-1`
echo "Linecount detected: $linecount Linecount used: $linecount_wanted"

if [ "$linecount_wanted" -gt 0 ]; then

# generate the new file
tail -n $linecount_wanted $mailboxtempfile > $mailboxnewfile

# third generate the the maildir data
mb2md -s $basedir/$mailboxnewfile -d $maildirpath/

# remove the temp file (another is removed below as it is always created)
rm -f $mailboxnewfile
else
echo " "
fi


# and remove the temp file
rm -f $mailboxtempfile

linecount=0;
linecount_wanted=0;

for additional_mbx_files in `ls $user/*.mbx | grep -v main.mbx`
do
echo "$user contained additional mbx file $additional_mbx_files"
done

done
(PS i was not as good at shell scripting back then so forgive the verbose nature - on the plus side it contains a fair few comments).
 
Old 10-30-2006, 07:31 PM   #3
wadesmart
Member
 
Registered: Jul 2005
Location: Oklahoma
Distribution: Ubuntu
Posts: 72

Original Poster
Rep: Reputation: 15
10302006 1908 GMT-6

I have made some backup directories of my mail and I have been experimenting.

I ran this command
Code:
mb2md -s /current_file_location -d /new_file_destination -R
and I got this

Code:
/new_file_destination/
 /cur
 /new
 /tmp

 /.Business
   /cur
    /1162256029.000000.mbox:2,S

 /.Business_sbd.Awareness Life
   /cur
     /1162256082.000000.mbox:2,S

What Im getting at is, Im not sure I understand what Im supposed to be seeing. It seems that under some of this folders there are /cur with items it them and under others, there isnt.

I had folders that I used to store mail in when I used Thunderbird and then later in Evolution. Is this creating a /cur /new and /tmp under each and every folder?

wade
 
Old 10-30-2006, 08:03 PM   #4
chakkerz
Member
 
Registered: Dec 2002
Location: Brisbane, Australia
Distribution: RedHat (RHEL, FC, CentOS), openSuSE, Mac OS X
Posts: 653

Rep: Reputation: 32
yes it is.

maildir uses those three folders, mail that is new gets moved (downloaded) to new and is then moved to cur. You may also find that if you did this on a server that you'd have a stack of hidden folders in there depending on what services you offer, like say an address book and a spam folder. Sadly i use $exchange in a vmware session to do my mail on this system so i can not show you what it looks like on here.

From (cloudy) memory this is due to how IMAP stores it's messages ...

Anyone else got more info?
 
Old 10-30-2006, 08:25 PM   #5
wadesmart
Member
 
Registered: Jul 2005
Location: Oklahoma
Distribution: Ubuntu
Posts: 72

Original Poster
Rep: Reputation: 15
10302006 2012 GMT-6

Ok. So let me ask this then.
One of the folders I had set up in Evolution was titled business and some subfolders under that.
Code:
/Business
 Awareness Life
 Beryl
 Currency
 Wireless

  /Wireless
    LocustWorld
    WISP

    /WISP
      Linux
      WiMax
      WISP-Equip

That is how it looks now in the /fixmail folder.
After I run the mb2md I end up with

Code:
/maildir
  /cur  0
  /new  0
  /tmp  0

  .Business_sbd
    /cur  0
    /new  0
    /tmp  0
  .Business_sbd.Awareness Life
    /cur  171
    /new  0
    /tmp  0
  .Business.sbd.Beryl
    /cur  23
    /new  0
    /tmp  0
Now, I guess what Im not totally getting is, I see that .Business_sbd has three folders under it but it itself doesnt store mail, its just a folder for other folders. Should I just copy all the mail documents only as in Awareness Life, Beryl, Currency and Wirelss, plus the ones under other sub folders and then just have mb2md run on those only? But if I do that, how will my rules work in my mail client?

Also, every folder under has _sbd on the end of it. Like.Business_sbd, .Business_sbd.Awareness Life, Business_sbd.Beryl and so on.

Im just wondering what that _sbd is and can it be stripped off?

wade
 
Old 10-31-2006, 01:21 PM   #6
wadesmart
Member
 
Registered: Jul 2005
Location: Oklahoma
Distribution: Ubuntu
Posts: 72

Original Poster
Rep: Reputation: 15
After running a lot of little tests I have noticed that if I delete these files

Code:
/folder
  *.cmeta
  *.ev-summary
  *.ibex.index
  *.ibex.index.data
that Im left with a plain text document that is the actual email that I need.

I think this mb2md is creating the correct folder structure ... based on that I have nothing else to go on I have to believe it is.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is Maildir and mbox vikasumit Linux - Software 11 06-03-2006 12:48 AM
popa3d and Maildir or mbox sulee Slackware 4 07-25-2005 08:45 AM
maildir and mbox deflin39 Linux - Newbie 1 01-07-2004 10:08 PM
Convert Maildir to Mbox leonardox Linux - Software 2 09-26-2003 11:23 PM
Differences? mbox vs maildir MasterC Linux - General 3 01-31-2003 03:44 AM


All times are GMT -5. The time now is 07:36 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration