Module: OnlyofficeIredmailHelper::MailboxesMethods

Included in:
IredMailHelper
Defined in:
lib/onlyoffice_iredmail_helper/mailboxes_methods.rb

Overview

Methods for working with Mail account Mailboxes

Instance Method Summary collapse

Instance Method Details

#create_mailbox(name) ⇒ nil

Create new mailbox with name

Parameters:

  • name (String)

    name of folder

Returns:

  • (nil)


19
20
21
22
23
24
25
# File 'lib/onlyoffice_iredmail_helper/mailboxes_methods.rb', line 19

def create_mailbox(name)
  
  @imap.select('INBOX')
  @imap.create(name)
  close
  OnlyofficeLoggerHelper.log("Created new mailbox: #{name}")
end

#delete_mailbox(name) ⇒ nil

Delete mailbox with name

Parameters:

  • name (String)

    name of folder

Returns:

  • (nil)


30
31
32
33
34
35
36
37
38
# File 'lib/onlyoffice_iredmail_helper/mailboxes_methods.rb', line 30

def delete_mailbox(name)
  raise("There is no mailbox #{name} to delete") unless mailboxes.include?(name)

  
  @imap.select('INBOX')
  @imap.delete(name)
  close
  OnlyofficeLoggerHelper.log("Delete mailbox by name: #{name}")
end

#mailboxesArray<String>

Returns list of folder names.

Returns:

  • (Array<String>)

    list of folder names



7
8
9
10
11
12
13
14
# File 'lib/onlyoffice_iredmail_helper/mailboxes_methods.rb', line 7

def mailboxes
  
  @imap.select('INBOX')
  folders = @imap.list('%', '%').map(&:name)
  close
  OnlyofficeLoggerHelper.log("Get list of mailboxes: #{folders}")
  folders
end