1
  /   ˆ{‹„„-i[D<†ªoZƒ›Ù«Â447_‘I|¥‰ÓMdœv ©ƒ†ü+=ÂÁ ¿    ‹      ¥“_oÓ0Åß÷).~à-¹é@Ú£‘T¢R×V]Ð4!ÜØI¬%q°¥|zœ¦h­‚ÁSûçsÏ¹7¦/ÒU’Ý¯gð>»YÀúÃ»Å< ÞMÄ4K‡�i�gK¤r®»DÜívánjSb¶ÁÊ5õ­3*w¡p‚°Ú¯± •äÂ?�:åjÉæ­�ß@€ú‹³JÈ)vFçè*ãÁÀÊº@£µC»·¸­uþ€µÖ]„ÍgŠƒ„Å£*Ýj±ï‹�þOØŸ?XäÛƒ~ÿju|åµ*Û˜8ÝFUS‚5yLPåºíexû–ª Àk“�ódõÉs¾hšQ¾z“·I¼¼ZÅ)aKÞHŠüiæÆ3×„-¸uÐh¡
%ÅYøv€oÕ÷ó‚éÀ¤ÒæFuNéöEñ4j®kÛqŸõ•OP™Sj@ÄŸºÁó_š±¾ÞÌ–Y:ß-½Ä£»çŽ‰°57²u�*#s§ÍþeÐ}ÙnmwõóŽF�*+G@ O’ÏHWèZHsšï\²Þk„§î~³3ŽÆ¯ƒÑ(O _NÞ ü“ï¿œÿjŠ‡ËBq¸™? ìÅ¬Lü       ˆÀ¿Ã647¾ÂÁ ‡    ‹      Õ—ßoÓ0Çßù+Œxk/É~A—�f[WmE!4¹±›XKìÈvÊ_�Sgk‡VÈÄ&º§;§_ûîcß%nø:¾L¾ŽOÑÇÉùþp6 Üø²7 ˆ'±ûa¿ëù §#ŒpfLÙ¨ªª[íu¥Jar	™)ò}ÐFñÄt©¡8zÖÏ¢W(Ì¡Ö¢Ðp“³h((û�ä�œÍ)³ó–([ð„éÚ7¬€‚R-spBRæARÎ} Š/˜ªý ·¦�M˜p*é²Žî?q$»à
‚LWkWE¡ÉÐ‚ä<}ld‰£�)Ò*écà‰¦97Ý”Ï0"¹éãoÃÁÅw«“Õ³£� L±Y¿ôGÇýG#R°ÈÃšs«9ÁÑÑ’ògt«øÊ‰¯øÏíÆN3�(^.ÅZ
q5‘¹.‰e=°™ÚT9	ýÛn�äÞfŒO.OG“xxé¶„ÖK¬³ûÇsÃÑ˜(&Š¹b‰±²†Ì…y#¦º<¾¢&oÅÓÌà¡zPùØ™Ì)S›¸Û@’dÌæëìf–¿¥xÁaÇ÷;þ;äõ¼#„ž1ÿ¹¸²› ¶PDg×B¦-ÅzÐ%ØC^ÐÞnE±ïžOÿåZÛÆ¹Ç³zÒÊëÞ³Bµ¯¯»†hœövø¬Öž`ÆUQÙn¾®ÛÜ‚Ü¿<žLš2Ÿ§–äÖkSU~]Už¿#î�‹#gwåÑêRä\Øwöåµu)«UW;Û&oU@»Òz>m>æ8Zû»RHí9ì|™Ëti1îÜøŸ³…½-áÈÙ§8†?·CË‹%4WîVWûÜ‹_¦sôM»    5   ˆl–Ðz¾”*i?u8 q—nÕ1hß�þB g]›	\ ÿŸÅƒh¹ÄÃÂ      0000004b
  D   	ˆl–Ým_J¥/”Š�zàƒp/©‹Fÿ�þD•fË(!#M�ÏÆƒy—Å_�uÐb&=LyZËcõÅÄ  ®    	# encoding: utf-8
# frozen_string_literal: true

module Mail
  # The IMAP retriever allows to get the last, first or all emails from a IMAP server.
  # Each email retrieved (RFC2822) is given as an instance of +Message+.
  #
  # While being retrieved, emails can be yielded if a block is given.
  #
  # === Example of retrieving Emails from GMail:
  #
  #   Mail.defaults do
  #     retriever_method :imap, { :address             => "imap.googlemail.com",
  #                               :port                => 993,
  #                               :user_name           => '<username>',
  #                               :password            => '<password>',
  #                               :enable_ssl          => true }
  #   end
  #
  #   Mail.all    #=> Returns an array of all emails
  #   Mail.first  #=> Returns the first unread email
  #   Mail.last   #=> Returns the last unread email
  #
  # You can also pass options into Mail.find to locate an email in your imap mailbox
  # with the following options:
  #
  #   mailbox: name of the mailbox used for email retrieval. The default is 'INBOX'.
  #   what:    last or first emails. The default is :first.
  #   order:   order of emails returned. Possible values are :asc or :desc. Default value is :asc.
  #   count:   number of emails to retrieve. The default value is 10. A value of 1 returns an
  #            instance of Message, not an array of Message instances.
  #   keys:    are passed as criteria to the SEARCH command.  They can either be a string holding the entire search string, 
  #            or a single-dimension array of search keywords and arguments.  Refer to  [IMAP] section 6.4.4 for a full list
  #            The default is 'ALL'
  #
  #   Mail.find(:what => :first, :count => 10, :order => :asc, :keys=>'ALL')
  #   #=> Returns the first 10 emails in ascending order
  #
  class IMAP < Retriever
    require 'net/imap' unless defined?(Net::IMAP)
    
    def initialize(values)
      self.settings = { :address              => "localhost",
                        :port                 => 143,
                        :user_name            => nil,
                        :password             => nil,
                        :authentication       => nil,
                        :enable_ssl           => false,
                        :enable_starttls      => false }.merge!(values)
    end

    attr_accessor :settings

    # Find emails in a IMAP mailbox. Without any options, the 10 last received emails are returned.
    #
    # Possible options:
    #   mailbox: mailbox to search the email(s) in. The default is 'INBOX'.
    #   what:    last or first emails. The default is :first.
    #   order:   order of emails returned. Possible value