1

I have been looking at various email setups using different tools within Emacs for the last few months. I looked at various email setups using Gnus, mew, mu4e, wanderlust etc.

While reading one of the setups on some blog, I was trying to setup offlineimap/mbsync. And it requires the name of folders to fetch. On one such blog there was a Perl script to fetch all these folder names automatically. and output them to a file. These folder names can then be used with other configuration scripts to specify which particular folders to fetch.

Now I have finally got a setup which I am staying with and it is working for me. It uses mbsync + mu4e . I have a lot of folders in my mail box as I used to use filters. I was only able to use INBOX and Sent Mails in that configuration, as other folders are a lot. And now I am again looking to find that Perl script.

Does any of you have came across such setup which uses some Perl magic to fetch folders for the configuration?

0

You can use Net::IMAP::Simple perl module/package.
Below please find "version zero" based on the man page.

#!/usr/bin/perl
use strict;
use warnings;
use Net::IMAP::Simple;

# Create the object
my $imap = Net::IMAP::Simple->new('imap.example.com', use_ssl => 1) ||
    die "Unable to connect to IMAP: $Net::IMAP::Simple::errstr\n";

# Log on
if(!$imap->login('user','pass')){
    print STDERR "Login failed: " . $imap->errstr . "\n";
    exit(64);
}

# List folders
my @folders   = $imap->mailboxes_subscribed;
foreach my $folder (@folders) {
   print $folder,"\n";
}
  • Thanks a lot, this works. – Raju Devidas Feb 7 at 12:10

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.