Module: OnlyofficeIredmailHelper::DeleteMethods

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

Overview

Methods to delete messages

Instance Method Summary collapse

Instance Method Details

#delete_all_messagesnil

Delete all messages in inbox

Returns:

  • (nil)


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

def delete_all_messages
  
  @imap.select('INBOX')
  @imap.store(@imap.search(['ALL']), '+FLAGS', [:Deleted]) unless @imap.search(['ALL']).empty?
  OnlyofficeLoggerHelper.log('Delete all messages')
  close
end

#delete_email_by_subject(subject) ⇒ nil

Delete email by subject

Parameters:

  • subject (String)

    email title

Returns:

  • (nil)


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

def delete_email_by_subject(subject)
  
  @imap.select('INBOX')
  id_emails = @imap.search(['SUBJECT', subject.dup.force_encoding('ascii-8bit')])
  @imap.store(id_emails, '+FLAGS', [:Deleted]) unless id_emails.empty?
  close
end