Skip to content

Latest commit

 

History

History
57 lines (40 loc) · 1.38 KB

README.md

File metadata and controls

57 lines (40 loc) · 1.38 KB

amnesia

A Crystal library for interacting with the temp-mail API.

Installation

Add this to your application's shard.yml:

dependencies:
  amnesia:
    github: z64/amnesia

Usage

See basics.cr in the examples directory.

# Print a list of available domains
puts Amnesia::EmailAddress.domains

# Bind an email address. This will perform a GET request
# to validate the domain is valid at the time of creation.
address = Amnesia::EmailAddress.new "[email protected]"
puts address.inspect

# Fetch this address' inbox.
emails = address.inbox
puts "bob has #{emails.size} emails."
puts emails.map { |e| e.inspect }.join "\n"

# Delete an email (uncomment this providing the account actually has emails)
# puts emails.first.delete
# puts address.inbox.size

# EmailAddress provides an interface to the basic REST
# binding. For cache functionality, use Amnesia::Client
# which has such functionality:
client = Amnesia::Client.new address
# You can also pass a string, like "[email protected]"
# like above with Amnesia::EmailAddress.

# Update the Client's inbox
# You can (optionally) pass a block to #poll! that
# will be called each time a *new* email is added to the cache.
client.poll! do |e|
  puts "new email! From #{e.from}: #{e.subject}"
end

Contributors

  • z64 - creator, maintainer