createMailbox method

Future<void> createMailbox({
  1. required String folderPath,
  2. required MailboxType type,
  3. int? maxMessages,
  4. int? retentionDays,
  5. int? retentionCount,
})

Create a new mailbox

Implementation

Future<void> createMailbox({
  required String folderPath,
  required MailboxType type,
  int? maxMessages,
  int? retentionDays,
  int? retentionCount,
}) async {
  _logger.fine('Creating mailbox: $folderPath (type: ${type.name})');

  final address = MailboxAddress(
    ownerId: host.id,
    folderPath: folderPath,
    type: type,
  );

  final request = CreateMailboxRequest(
    address: address,
    maxMessages: maxMessages,
    retentionDays: retentionDays,
    retentionCount: retentionCount,
  );

  final response = await _sendRequest(request);
  if (!response.success) {
    throw MailboxManagementError(
      response.errorMessage ?? 'Failed to create mailbox',
    );
  }

  _logger.info('Created mailbox: ${address.fullPath}');
}