Hello,
Why not use a tool to get the list?
----8<------------------------------------------------------------------
#!/usr/bin/perl
use Net::IMAP::Simple;
use strict;
use Getopt::Long;
my $PASS="sag_ich_nischt";
my $USER="linux4michelle";
my $HOST="mx.freenet.de";
GetOptions('user=s'  => \$USER,
           'pass=s'  => \$PASS,
           'host=s'  => \$HOST);
die "Kein Benutzer angegeben\n" unless $USER;
die "Kein Password angegeben\n" unless $PASS;
die "Kein Host angegeben\n"     unless $HOST;
my $imap = Net::IMAP::Simple->new($HOST) || die
$Net::IMAP::Simple::errstr."\n";
unless($imap->login($USER, $PASS)){
        die "Login failed: " . $imap->errstr() . "\n";
}
my @mb=$imap->mailboxes;
foreach (@mb){
    printf "$_\n";
};
----8<------------------------------------------------------------------
Thanks, Greetings and nice Day/Evening
    Michelle Konzack
    Systemadministrator
    24V Electronic Engineer
    Tamay Dogan Network
    Debian GNU/Linux Consultant
-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
Michelle Konzack   Apt. 917                  ICQ #328449886
+49/177/9351947    50, rue de Soultz         MSN LinuxMichi
+33/6/61925193     67100 Strasbourg/France   IRC #Debian (irc.icq.com)
Attachment:
signature.pgp
Description: Digital signature