class Mail::Retriever - mail-2.5.4 Documentation

# class Mail::Retriever

### Public Instance Methods

all(options = {}, &block) click to toggle source

Get all emails.

Possible options:

    order: order of emails returned. Possible values are :asc or :desc. Default value is :asc.

    # File lib/mail/network/retriever_methods/base.rb, line 37
    def all(options = {}, &block)
      options ||= {}
      options[:count] = :all
      find(options, &block)
    end

find_and_delete(options = {}, &block) click to toggle source

Find emails in the mailbox, and then deletes them. Without any options, the five last received emails are returned.

Possible options:

    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.
    delete_after_find: flag for whether to delete each retreived email after find. Default
            is true. Call #find if you would like this to default to false.

    # File lib/mail/network/retriever_methods/base.rb, line 54
    def find_and_delete(options = {}, &block)
      options ||= {}
      options[:delete_after_find] ||= true
      find(options, &block)
    end

first(options = {}, &block) click to toggle source

Get the oldest received email(s)

Possible options:

    count: number of emails to retrieve. The default value is 1.
    order: order of emails returned. Possible values are :asc or :desc. Default value is :asc.

    # File lib/mail/network/retriever_methods/base.rb, line 12
    def first(options = {}, &block)
      options ||= {}
      options[:what] = :first
      options[:count] ||= 1
      find(options, &block)
    end

last(options = {}, &block) click to toggle source

Get the most recent received email(s)

Possible options:

    count: number of emails to retrieve. The default value is 1.
    order: order of emails returned. Possible values are :asc or :desc. Default value is :asc.

    # File lib/mail/network/retriever_methods/base.rb, line 25
    def last(options = {}, &block)
      options ||= {}
      options[:what] = :last
      options[:count] ||= 1
      find(options, &block)
    end