Email
A user who gives an email contact can also have support's answers sent to it, and reply by email: the reply joins their report's thread, as if they'd written it in the app. Support can be told of new reports and replies by email too (Notifications). This page is the app's side; the servers are in Self-hosting.
Answers by email
Nothing is ever sent to a contact the user didn't ask for, and nothing goes to an address until its owner confirms it:
- The product offers it. On the panel, the product's email settings have Answers by email on, and mail can go out.
GET /api/v1/productthen saysemail_answers: true. Offer the choice only then. - The user asks. Beside the email field, a tick box such as Also send me support's answers by email. The client sends it with the contact (
email_answersinsetContact), or on its own later (setEmailAnswers(true),POST /api/v1/me/contact/answers). - A link is mailed to the address. The contact's
email_answersispendinguntil the link is opened and confirmed (it works for 7 days). Asked again while pending, the link is sent again, three times an hour at most. Tell the user to look for it. - Answers come by email once it's
on: each of support's answers in an ordinary ticket, with the ticket's number. Live conversations stay in the app.
Every mail has a link to stop them, and mail apps' one-click unsubscribe works too. The client can stop them as well (setEmailAnswers(false)). The user's anonymous id is never in their mail: the links carry it sealed. A new address ends the old one's answers until it's confirmed in turn; the same address given again keeps them on.
The contact's state is off, pending or on, in getContact and me. Show it: Waiting for you to confirm the address, Answers come by email too.
Replies by email
An answer comes from the product's reply address with the ticket after a + (help+12.road-builder.k3x9q@example.com), and refers to a message naming the ticket too. A reply to it:
- joins the ticket's thread as the user's, with
via: "email"on its entry (show it, if you like: by email); - is what the user wrote above the quoted mail, without their signature, after the product's redaction rules;
- brings the attachments the product takes, within its limits; the rest are left out;
- reopens a ticket waiting on the user, or resolved, as a reply in the app does.
It isn't taken if it comes from another address than the one the user confirmed, if it's an automatic mail (an out-of-office reply, a bounce, a list), or if answers by email are off. A reply to a closed ticket, or one that's live in the app, isn't taken either, and the user is told once by mail to open the app instead.
Getting the replies in
Replies reach ALIAS in one of two ways. Use whichever your mail already does.
A mailbox, over IMAP. The deployment's, or a product's own, set on the panel or in the configuration file. ALIAS reads its new unread mail every minute and marks as read the replies it takes. Give it a mailbox of its own.
Posted by your mail provider. Point the provider's inbound route at:
POST /api/v1/inbound/email, with the deployment's secret (ALIAS_EMAIL_INBOUND_SECRET): any product's replies;POST /api/v1/inbound/email/<product>, with a product's own secret (made on its email page, shown once): its replies only.
The secret goes as a bearer token, or as basic auth's password for a provider that can't set headers (https://api:SECRET@support.example.com/...). The body is the mail as it came (message/rfc822), or a form with it in body-mime, email or message. ?to= can say where it was delivered. Each mail is taken once, by its Message-ID, so a provider's retry does no harm; the answer is 200 whatever became of it, with result and reason.
Cloudflare Email Workers
An Email Routing rule sends the reply address (and its + addresses) to a Worker that posts the mail on:
// Illustration: a Worker forwarding replies to ALIAS
export default {
async email(message, env) {
const res = await fetch(`https://support.example.com/api/v1/inbound/email?to=${encodeURIComponent(message.to)}`, {
method: 'POST',
headers: { 'Authorization': `Bearer ${env.ALIAS_INBOUND_SECRET}`, 'Content-Type': 'message/rfc822' },
body: message.raw,
})
if (!res.ok) message.setReject(`ALIAS: ${res.status}`)
},
}Mailgun
A route matching the reply address, with the action forward to a URL. Mailgun posts the whole mail (in body-mime) only to a URL that ends in mime, so end it with a query ALIAS ignores: https://api:SECRET@support.example.com/api/v1/inbound/email?format=mime. The delivery address comes in recipient.
SendGrid Inbound Parse
Add the host the reply address is on, with POST the raw, full MIME message ticked, and the URL https://api:SECRET@support.example.com/api/v1/inbound/email. The mail goes in the email field.
Notifications for support
These aren't the app's business, but your team may ask: a product can tell team addresses of new reports and replies, and each support person can ask for their own, at their sign-in's email (Products). By default they say only that there's something, with a link to the panel; the user's words go in them only if the product says so.