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',
    writeTimeout: defaultWriteTimeout,
    responseTimeout: defaultResponseTimeout,
  );
  final parser = NoopParser(
    this,
    _selectedMailbox ??
        Mailbox(
          encodedName: path,
          encodedPath: path,
          flags: [MailboxFlag.noSelect],
          pathSeparator: serverInfo.pathSeparator ?? '/',
        ),
  );
  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.');
}