createMailbox method

Future<Mailbox> createMailbox(
  1. String path
)

Creates a new mailbox with the specified path

Implementation

Future<Mailbox> createMailbox(String path) async {
  final encodedPath = _encodeMailboxPath(path);
  final cmd = Command('CREATE $encodedPath');
  final parser = NoopParser(this,
      _selectedMailbox ?? Mailbox.setup(path, path, [MailboxFlag.noSelect]));
  await sendCommand<Mailbox>(cmd, parser);
  final matchingBoxes = await listMailboxes(path: path);
  if (matchingBoxes.isNotEmpty) {
    return matchingBoxes.first;
  }
  throw ImapException(this,
      'Unable to find just created mailbox with the path [$path]. Please report this problem.');
}