Skip to content
/ yugo Public
forked from Flying-Toast/yugo

Yugo is an easy and high-level IMAP client library for Elixir.

License

Notifications You must be signed in to change notification settings

skygroup2/yugo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yugo

Yugo is an easy and high-level IMAP client library for Elixir.

To begin, start a Yugo.Client as part of your application's supervision tree:

defmodule MyApp.Application do
  use Application

  @impl true
  def start(_type, _args) do
    children = [
      {Yugo.Client,
       name: :example_client,
       server: "imap.example.com",
       username: "[email protected]",
       password: "pa55w0rd"}
    ]

    Supervisor.start_link(children, strategy: :one_for_one)
  end
end

Now you can call Yugo.subscribe/2 to have your process receive messages whenever a new email arrives that matches the provided Yugo.Filter:

# filter to only notify us about messages containing "hello" or "goodbye" in the subject:
my_filter =
  Yugo.Filter.all()
  |> Yugo.Filter.subject_matches(~r/(hello|goodbye)/)

# By subscribing, our process will be notified about all future emails that match the filter.
Yugo.subscribe(:example_client, my_filter)

receive do
  {:email, _client, message} ->
    IO.puts("Received an email with subject `#{message.subject}`:")
    IO.inspect(message)
end

About

Yugo is an easy and high-level IMAP client library for Elixir.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Elixir 100.0%