Page MenuHomePhabricator

Improve inbound email options by extending Mailgun adapter to support the "store()" route action
Closed, DuplicatePublic

Description

Preface

First off, if this sounds useful, I might be willing to take a stab at it, if someone could give me a high-level intro of where to start (what files to create, where to look for good example code, etc..)

The Problem

The nature of my Phabricator install leaves us unable to receive inbound email. It is hosted on a machine in the office that cannot in any way be accessed by the outside world. (IT, bureaucracy, etc...).

The inbound setup steps for the current Mailgun adapter require that Mailgun users configure a catchall() route with the action forward("http://my.install.url/mail/mailgun")

Mailgun supports an alternate action, store(), which keeps the inbound message available via a GET request for 3 days.

Idea

Create a daemon that polls Mailgun's HTTP API every n seconds.

  1. Make a GET to the /events endpoint, requesting all storage events with a filter akin to: where ID > { last known ID }
    • Each item in the response contains a storage.url field.
  2. For each email waiting on the server, retrieve it via a GET to the URL provided in storage.url
    • The response contains the entirety of the email (headers & message body)

That's it. It would be high value for my team, but I don't know how common our setup is.

Disclaimer

The author of this task didn't know what MTA stood for until about 45 minutes ago. Nuff said.

Event Timeline

mholden raised the priority of this task from to Needs Triage.
mholden updated the task description. (Show Details)
mholden updated the task description. (Show Details)
mholden updated the task description. (Show Details)
mholden added a subscriber: mholden.
joshuaspence renamed this task from Request: Improve inbound email options by extending Mailgun adapter to support the "store()" route action to Improve inbound email options by extending Mailgun adapter to support the "store()" route action.Feb 14 2015, 8:16 AM
joshuaspence added a project: Mail.
joshuaspence added a subscriber: joshuaspence.
joshuaspence removed a subscriber: joshuaspence.

I think the more common case of this is probably T1109, where you send mail to, say, a Gmail account, and then we log in to the account and retrieve it.

If we supported that, would that work for you?

I think Phabricator can currently be configured in such a way that the address can be any address (including a personal address, and does not need to be tied to the Phabricator domain), so you could just register a new replytophabricator@gmail.com address, then mail goes to replytophabricator+D123+adsb8hasb@gmail.com. But basically you can make it as compliant as you're able to, down to a basis case of not needing any IT coordination.

The store() thing doesn't seem bad either, but we'd probably want to do IMAP first to get the infrastructure up.

mholden added a comment.EditedFeb 14 2015, 3:34 PM

Thanks getting back so fast!

I think Phabricator can currently be configured in such a way that the address can be any address (including a personal address, and does not need to be tied to the Phabricator domain), so you could just register a new replytophabricator@gmail.com address, then mail goes to replytophabricator+D123+adsb8hasb@gmail.com.

Where in that sequence (and/or what piece of configuration did I miss) does Phabricator have the ability to retrieve the contents of the inbox at replytophabricator+D123+adsb8hasb@gmail.com and react accordingly?

Thanks again.

Or... derp.. were you saying that after T1109, such a configuration would start working.

It doesn't, currently. T1109 describes building that capability.

In both that case and this one, the core infrastructure ("pull mail from an external mailbox") would be the same. In T1109, the desire is to pull from an IMAP mailbox; here the desire is to pull from a Mailgun HTTP mailbox. My sense is that IMAP mailboxes are probably more useful to more people, so I'm mostly wondering if that would be good enough.

Gotcha, and I think you're 100% right that IMAP would be the way to go.

Cool. I'm going to merge this into T1109 and just make a note about Mailgun there. It should be reasonable to build the actual "go pull mail from a mailbox" bit in a modular way so that we can support this and other pull-based mail retrieval eventually, but IMAP should probably be the first one.