Skip to content

Instantly share code, notes, and snippets.

@phaer
Created June 19, 2015 14:47
Show Gist options
  • Save phaer/375870cba44ab1c3b2ca to your computer and use it in GitHub Desktop.
Save phaer/375870cba44ab1c3b2ca to your computer and use it in GitHub Desktop.
roundcube: subscribe to all mailboxes
<?php
define('RCUBE_CONFIG_DIR', '/var/lib/roundcube/config/');
define('RCUBE_PLUGINS_DIR', '/var/lib/roundcube/plugins/');
require_once '/var/lib/roundcube/program/lib/Roundcube/bootstrap.php';
$rcube = rcube::get_instance(rcube::INIT_WITH_DB | rcube::INIT_WITH_PLUGINS);
$imap = $rcube->get_storage();
$imap->connect($HOST, $USER, $PASSWORD, $PORT , $SSL);
$all_folders = $imap->list_folders();
$subscribed_folders = $imap->list_folders_subscribed();
$unsubscribed_folders = array_diff($all_folders, $subscribed_folders);
print('all: ' . count($all_folders) . ' sub: ' . count($subscribed_folders) . ' unsub: ' . count($unsubscribed_folders) . "\n");
foreach($unsubscribed_folders as $folder) {
$result = $imap->subscribe(array($folder));
print($folder . ': ' . $result . "\n");
}
$imap->clear_cache('mailboxes', true);
$imap->close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment