-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs #12
Comments
Hi @yok0 defmodule Namespace.Mailroom do
use Mailroom.Inbox
match do
to("email@example.com")
# recipient(~r/^.+@mydomain\.com$/i)
subject(~r/a subject/)
has_attachment?
fetch_mail #Previous matching is done on headers and IMAP envelope, if the match succeeds and you need the body, then this will retrieve the message body
process(SomeModule, :some_function)
end
match do
to("wrong@example.com")
ignore
end
def config([app, key]) do
Keyword.merge(
[debug: false, folder: :inbox, assigns: %{}],
Application.get_env(app, key, [])
)
end
end
defmodule SomeModule do
def some_function(%MessageContext{}) do
#...
end
end To answer your issue about the missing examples, IMAP doesn’t have retrieve or delete but POP3 does |
Wow, this example helped a lot! Would be great if you could show some code that extracts attachments from an Email |
Hi @gernotkogler message
|> Mail.get_attachments()
|> Enum.each(fn {filename, contents} ->
# ... do something with the attachment
end) PS. If you want to make your life much easier, I have launched a service, Mailcast that processes emails and sends them to you via webhook. Let me know if you’d like a demo |
Thanks for the quick response. I figured out that I could use Mail to get to the attachments in the meantime, but your code snippet is a bit more concise. I was reasoning about I guess some work on the docs would attract way more people. If I hadn't found your snippet in the Docs issue today, I would have given up on mailroom. Now I have a perfect solution for my needs with just about 50 lines of code, great, thanks for your nice work! Using a third party service is not an option for me since the emails I process are confidential. And, by the way, the site seems to have issues, it renders a big SORRY. Let me know if you would accept a PR that documents the inbox usage in the README. |
Wrong link 🤦♂️ I’ve updated it. |
Looks good, cool idea. I actually wondered if I could use a service that calls a webhook when emails arrive, but as I said, my emails are confidential. May I ask you one more question? When I receive emails from an iPhone that just contain an image, the image is rendered inline. |
I’ve sent you an email to take discussion of confidentiality offline. I have seen that. Hey.com seems to do the same thing. I saw the comment on elixir-mail. I’ll have a look further there. |
Any plans on updating docs or is this project being archived? I am having hard time figuring out how to use Mailroom.
Also some of the functions in the existing examples arseems to be no longer there, like IMAP.retrive
and IMAP.delete.
Thanks
The text was updated successfully, but these errors were encountered: