1

I'm building a PHP app which should somehow receive emails that are to be imported into user records. None of the solutions I've come up with will work (listed and explained below). I'm hoping someone out there has a possible solution.

Our organization's email is hosted by Google, and so I can use the Google API to access the mail account.

The intended workflow is:

  1. Client emails a central email address that people access through delegation.
  2. An Agent does some action that indicates the email thread should be associated with the Client's account in the app.
  3. The app is somehow informed that a particular email is to be imported, and does so.

I've tried a number of solutions:

  1. Initially the app had a simple read-only re-creation of the inbox. This re-creation allowed the Agents to associate a particular email with any account in the app with a click of a button and filling out a modal form. This method proved less than ideal however, as Agents typically had to respond or file the email - for which they had to go back into GMail.

  2. We had also thought of making a new MX record and server so Agents could simply forward the email to [client's ID]@app.mydomain.com. This was denied by management though as maintaining an email server is a lot of work.

  3. Next up was having the Agent forward the email to [email protected] AND [client's ID]@app.mydomain.com. Even though app.mydomain.com doesn't exist, the app could check the [email protected] address, and parse who else the email was sent to. However this caused a bunch of "Email not sent" messages from Google.

  4. Finally I thought we could have the agents forward the email to [email protected] manually, and include in the body some special key that the app would look for. Typically this sort of thing is put into the subject and looks like [REF:12588F3T6YYB]. Our special key would look like [appname:client-id,other-client-id,etc]. Right now it looks like this is the best solution. I tried to build a GMail Add-On that would simplify this process, but Add-ons can't be run when the account is accessed through delegation.

Is there a magic 5th option that will be easy for our Agents to use?

1
  • 1
    Gmail uses/supports the "address extension" character + - so user+tag@gmail gets delivered to user@gmail. Set up a processing@yourco and using option #2 send the emails to processing+tag@yourco, the tag will remain and can be accessed, filtered on, etc.
    – ivanivan
    Commented Oct 13, 2018 at 16:05

1 Answer 1

1

My comment feels more like an answer, so reposting and fleshing out.

Your #2 is easy to implement, and doesn't require a new MX ...

Gmail uses/supports the "address extension" character +, so user+tag@gmail gets delivered to user@gmail, but maintains the +tag part as the original To: field.

So....

1) Create a new email account - say, "appname_tickets@yourco", set a password, allow imap access, etc.

2) Clients email "support@yourco". This is your typical shared incoming box. Agent(s) check this, and then ...

3) Agents forward emails as appropriate to "appname_tickets+clientID@yourco" or "appname+clientID_ticketNumber@" or whatever tagging system you care to use. Just use a single + to separate the left side (real email username localpart) and the right side (extended address/tag)

4) In your PHP code, use the various IMAP functions to poll for new mail, checking the headers for the full To: address, parsing that, and then continuing on with whatever processing you need to do on the message.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.