Outwright Alpha, iPhone and iPad GitHub

Set up Dovecot push notifications

New-mail notifications for Outwright on Dovecot 2.4 and 2.3.

What it does

A small Lua script connects Dovecot to Outwright's push relay. When mail arrives in a user's Inbox, the script notifies the relay, which asks Apple to wake the user's iPhone. Outwright then fetches the new mail directly from your server.

The script sends no message content or email addresses. It can send requests only to Outwright's push relay, even if a user tries to configure another destination. Push notifications are a paid feature. Each user enables them in Outwright's account settings.

What you need

  • Dovecot 2.4 or 2.3, delivering mail over LMTP or LDA.
  • Dovecot's Lua plugins, which are part of dovecot-core on Debian and Ubuntu.
  • The script, outwright-push.lua, which you can read before you install it. It is also on GitHub with these config files: outwright-dovecot-push.

Install the script

mkdir -p /usr/local/share/outwright
curl -o /usr/local/share/outwright/outwright-push.lua https://outwright.app/push/outwright-push.lua
doveadm reload

Dovecot 2.4

Save the following configuration in the file named below. If an existing protocol lmtp or protocol lda block sets its own mail_plugins, add the four plugins there too.

# /etc/dovecot/conf.d/90-outwright-push.conf (Dovecot 2.4)
mail_attribute {
  dict file {
    path = %{home}/dovecot-attributes
  }
}
protocol imap {
  imap_metadata = yes
}
mail_plugins {
  notify = yes
  push_notification = yes
  mail_lua = yes
  push_notification_lua = yes
}
push_notification lua {
  lua_file = /usr/local/share/outwright/outwright-push.lua
  lua_settings {
    relay_base = https://push.outwright.app/v1/push/
  }
}

Dovecot 2.3

Save the following configuration in the file named below. If protocol lmtp or protocol lda sets mail_plugins at all, even with $mail_plugins, add the four plugins there too: Dovecot 2.3 does not carry a later global setting into an earlier protocol block, and doveconf -n warns about it.

# /etc/dovecot/conf.d/90-outwright-push.conf (Dovecot 2.3)
mail_plugins = $mail_plugins notify push_notification mail_lua push_notification_lua
mail_attribute_dict = file:%h/dovecot-attributes
protocol imap {
  imap_metadata = yes
}
plugin {
  push_notification_driver = lua:file=/usr/local/share/outwright/outwright-push.lua
  outwright_push_relay_base = https://push.outwright.app/v1/push/
}

Check that it works

Run doveadm reload, then switch on Notifications for the account in Outwright. The app saves a small check message to the Inbox, already read and deleted, and removes it again within seconds; the switch stays on only after the app receives a response through the relay. If it says the server is not set up for push, look for outwright push in Dovecot's log.