Giter VIP home page Giter VIP logo

dovecot-xaps-plugin's Introduction

iOS Push Email for Dovecot

What is this?

This project, together with the dovecot-xaps-daemon project, will enable push email for iOS devices that talk to your Dovecot 2.0.x IMAP server. This is specially useful for people who are migrating away from running email services on OS X Server and want to keep the Push Email ability.

Please note that it is not possible to use this project without legally owning a copy of OS X Server. You can purchase OS X Server on the Mac App Store or download it for free if you are a registered Mac or iOS developer.

High Level Overview

There are two parts to enabling iOS Push Email. You will need both parts for this to work.

First you need to install the Dovecot plugins from this project. The Dovecot plugins add support for the XAPPLEPUSHSERVICE IMAP extension that will let iOS devices register themselves to receive native push notifications for new email arrival.

(Apple did not document this feature, but it did publish the source code for all their Dovecot patches on the Apple Open Source project site, which include this feature. So although I was not able to follow a specification, I was able to read their open source project and do a clean implementation with all original code.)

Second, you need to install a daemon process, from the dovecot-xaps-plugin project, that will be responsible for receiving new email notifications from the Dovecot Local Delivery Agent or from the Dovecot LMTP server and transforming those into native Apple Push Notifications.

Installation

Prerequisites

You are going to need the following things to get this going:

  • Some patience and willingness to experiment - Although I run this project in production, it is still a very early version and it may contain bugs.
  • Because you will need a certificate to talk to the Apple Push Notifications Service, you can only run this software if you are migrating away from an existing OS X Server setup where you had Push Email enabled. How to export the certificate is described in the dovecot-xaps-daemon project.
  • Dovecot > 2.2.19 (which introduced the push-notification plugin)

Note that you need to have an existing Dovecot setup working. Either with local system users or with virtual users. Also note that you need to be using the Dovecot Local Delivery Agent or the Dovecot LMTP server for this to work. The Dovecot LDA and the LMTP server are described in detail on the Dovecot Wiki

Installing the Dovecot plugins

First install the following Ubuntu 12.04.5 packages, or equivalent for your operating system. This list is longer than it should be because there is not yet a binary distribution for this project.

sudo apt-get build-dep dovecot-core
sudo apt-get install git dovecot-dev cmake

Clone this project:

git clone https://github.com/st3fan/dovecot-xaps-plugin.git
cd dovecot-xaps-plugin

Compile and install the plugins. Note that the installation destination in the Makefile is hardcoded for Ubuntu, it expects the Dovecot modules to live at /usr/lib/dovecot/modules/. You can either modify the Makefile or copy the modules to the right place manually.

mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
sudo make install

Install the configuration file. Also specific for Ubuntu, may be different for your operating system.

sudo cp xaps.conf /etc/dovecot/conf.d/95-xaps.conf

In the configuration file, change the xaps_socket option to point to the same location as you specified on the xapsd daemon arguments.

Restart Dovecot:

sudo service dovecot restart

Debugging

Put a tail on /var/log/mail.log and keep an eye on the output of the xapsd daemon. (See instructions in that project). If you see any errors or core dumps, please file a bug.

dovecot-xaps-plugin's People

Contributors

mstilkerich avatar st3fan avatar w194 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dovecot-xaps-plugin's Issues

dovecot-username differs

Thank You for implantation of Push for Dovecot.
I was very frustrated about Apples Server.
Only a simple Update resets Settings on there App. For Example: the config of the Webserver was totally removed, and after Update, i was not able to Download Attachments from Wiki-Server.
So i switched to Linux (Rebuild OD and all other Services from Apple Server)

After a few Hours of Work, I've got it to work, an i have a small issue.
The Device register with dovecot-name "username" but when i receive an Mail, the Plugin sends the name with domain: dovecot-name [email protected], so my device can't receive the Push Notification.
I edited the xapsd.json and replace the username with [email protected] and now it works fine.

Some logs:

35B470', 'dovecot-mailboxes': ['Sent', 'Notes', 'INBOX'], 'dovecot-username': 'uzilurcs', 'aps-subtopic': 'com.apple.mobilemail'})
2015-03-24 20:34:38+0100 [XAPSProtocol,1,] handleRegister: Command(name='REGISTER', args={'aps-account-id': '3B85D161-24B6-4A97-9AA7-4CE7CA279C6A', 'aps-device-token': 'B2C573AECD88D863E23A3CA12848D2CFEF4855080667FC94075043476D35B470', 'dovecot-mailboxes': ['Sent', 'Notes', 'INBOX'], 'dovecot-username': 'username', 'aps-subtopic': 'com.apple.mobilemail'})

2015-03-24 20:39:34+0100 [XAPSProtocol,7,] lineReceived: NOTIFY dovecot-username="[email protected]" dovecot-mailbox="INBOX"
2015-03-24 20:39:34+0100 [XAPSProtocol,7,] Command(name='NOTIFY', args={'dovecot-username': '[email protected]', 'dovecot-mailbox': 'INBOX'})
2015-03-24 20:39:34+0100 [XAPSProtocol,7,] handleNotify: Command(name='NOTIFY', args={'dovecot-username': '[email protected]', 'dovecot-mailbox': 'INBOX'})
2015-03-24 20:39:34+0100 [XAPSProtocol,7,] APNSClientFactory.queueNotification
2015-03-24 20:39:34+0100 [XAPSProtocol,7,] APNSClientFactory.queueNotification
2015-03-24 20:39:34+0100 [XAPSProtocol,7,] APNSClientFactory.queueNotification
2015-03-24 20:39:34+0100 [XAPSProtocol,7,] APNSClientFactory.queueNotification
2015-03-24 20:39:34+0100 [XAPSProtocol,7,] APNSClientFactory.queueNotification
2015-03-24 20:39:34+0100 [XAPSProtocol,7,] APNSClientFactory.queueNotification
2015-03-24 20:39:34+0100 [XAPSProtocol,7,] APNSClientFactory.queueNotification

And another Question. I it possible to got it to work with Darwin Calendarserver on Linux?

Thanks

Support subscribing to subfolders

When connected to the dovecot-xaps-plugin, iOS offers to choose which mailboxes/imap subfolders should be pushed.
Two parts are needed for this:

The plugin only needs to notify the daemon when:

  • mail is flagged as unseen
  • new mail is saved that is unseen
  • mail is moved that is unseen

The daemon then looks up if the client is subscribed to this mailbox/subfolder and sends a notification.

Not working for some reason?

Greetings!

I just set this up on my dovecot server. I have the certificate, and could do the openssl test just fine. I can see where my mailbox has the INBOX and notes folder show up in the json file, and I can see lines like this in the mail.log file :

2014-10-18 21:54:20-0500 [XAPSProtocol,57,] lineReceived: REGISTER aps-account-id="0A7C4DFD-3FC4-418D-B4FC-F6EE59603731" aps-device-token="3A1E4FBA6214E9DB210D15BAF10D5EE85ED217437B9BAC4AFACB8416AAD6E46D" aps-subtopic="com.apple.mobilemail" dovecot-username="[email protected]" dovecot-mailboxes=("INBOX","Notes")
2014-10-18 21:54:20-0500 [XAPSProtocol,57,] Command(name='REGISTER', args={'aps-account-id': '0A7C4DFD-3FC4-418D-B4FC-F6EE59603731', 'aps-device-token': '3A1E4FBA6214E9DB210D15BAF10D5EE85ED217437B9BAC4AFACB8416AAD6E46D', 'dovecot-mailboxes': ['INBOX', 'Notes'], 'dovecot-username': '[email protected]', 'aps-subtopic': 'com.apple.mobilemail'})
2014-10-18 21:54:20-0500 [XAPSProtocol,57,] handleRegister: Command(name='REGISTER', args={'aps-account-id': '0A7C4DFD-3FC4-418D-B4FC-F6EE59603731', 'aps-device-token': '3A1E4FBA6214E9DB210D15BAF10D5EE85ED217437B9BAC4AFACB8416AAD6E46D', 'dovecot-mailboxes': ['INBOX', 'Notes'], 'dovecot-username': '[email protected]', 'aps-subtopic': 'com.apple.mobilemail'})
2014-10-18 21:55:04-0500 [XAPSProtocol,58,] lineReceived: REGISTER aps-account-id="0A7C4DFD-3FC4-418D-B4FC-F6EE59603731" aps-device-token="3A1E4FBA6214E9DB210D15BAF10D5EE85ED217437B9BAC4AFACB8416AAD6E46D" aps-subtopic="com.apple.mobilemail" dovecot-username="[email protected]" dovecot-mailboxes=("INBOX","Notes")
2014-10-18 21:55:04-0500 [XAPSProtocol,58,] Command(name='REGISTER', args={'aps-account-id': '0A7C4DFD-3FC4-418D-B4FC-F6EE59603731', 'aps-device-token': '3A1E4FBA6214E9DB210D15BAF10D5EE85ED217437B9BAC4AFACB8416AAD6E46D', 'dovecot-mailboxes': ['INBOX', 'Notes'], 'dovecot-username': '[email protected]', 'aps-subtopic': 'com.apple.mobilemail'})
2014-10-18 21:55:04-0500 [XAPSProtocol,58,] handleRegister: Command(name='REGISTER', args={'aps-account-id': '0A7C4DFD-3FC4-418D-B4FC-F6EE59603731', 'aps-device-token': '3A1E4FBA6214E9DB210D15BAF10D5EE85ED217437B9BAC4AFACB8416AAD6E46D', 'dovecot-mailboxes': ['INBOX', 'Notes'], 'dovecot-username': '[email protected]', 'aps-subtopic': 'com.apple.mobilemail'})
2014-10-18 21:55:53-0500 [XAPSProtocol,59,] lineReceived: REGISTER aps-account-id="0A7C4DFD-3FC4-418D-B4FC-F6EE59603731" aps-device-token="3A1E4FBA6214E9DB210D15BAF10D5EE85ED217437B9BAC4AFACB8416AAD6E46D" aps-subtopic="com.apple.mobilemail" dovecot-username="[email protected]" dovecot-mailboxes=("INBOX","Notes")
2014-10-18 21:55:53-0500 [XAPSProtocol,59,] Command(name='REGISTER', args={'aps-account-id': '0A7C4DFD-3FC4-418D-B4FC-F6EE59603731', 'aps-device-token': '3A1E4FBA6214E9DB210D15BAF10D5EE85ED217437B9BAC4AFACB8416AAD6E46D', 'dovecot-mailboxes': ['INBOX', 'Notes'], 'dovecot-username': '[email protected]', 'aps-subtopic': 'com.apple.mobilemail'})
2014-10-18 21:55:53-0500 [XAPSProtocol,59,] handleRegister: Command(name='REGISTER', args={'aps-account-id': '0A7C4DFD-3FC4-418D-B4FC-F6EE59603731', 'aps-device-token': '3A1E4FBA6214E9DB210D15BAF10D5EE85ED217437B9BAC4AFACB8416AAD6E46D', 'dovecot-mailboxes': ['INBOX', 'Notes'], 'dovecot-username': '[email protected]', 'aps-subtopic': 'com.apple.mobilemail'})

When I send a message to this account, I see this in the log file :

2014-10-18 21:57:46-0500 [XAPSProtocol,60,] lineReceived: NOTIFY dovecot-username="[email protected]" dovecot-mailbox="INBOX"
2014-10-18 21:57:46-0500 [XAPSProtocol,60,] Command(name='NOTIFY', args={'dovecot-username': '[email protected]', 'dovecot-mailbox': 'INBOX'})
2014-10-18 21:57:46-0500 [XAPSProtocol,60,] handleNotify: Command(name='NOTIFY', args={'dovecot-username': '[email protected]', 'dovecot-mailbox': 'INBOX'})
2014-10-18 21:57:46-0500 [XAPSProtocol,60,] APNSClientFactory.queueNotification
2014-10-18 21:57:48-0500 [-] APNSProtocol.sendNotifications (1)

The "sendNotifications" line just above makes me think it should be working, yet I receive no notification on my iPhone. iPhone is set for push - not for fetch or manual.

Please help..

Thanks,

Tim

Why does the plugin return asp-version 2 even if client is v1

OS X Server 5.1.7
`* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE XAPPLEPUSHSERVICE AUTH=CRAM-MD5 AUTH=PLAIN AUTH=LOGIN AUTH=DIGEST-MD5] Dovecot ready. a1 LOGIN stefan xxx a1 OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS SPECIAL-USE BINARY MOVE XAPPLEPUSHSERVICE SEARCH=FUZZY URLAUTH URLAUTH=BINARY COMPRESS=DEFLATE QUOTA ACL RIGHTS=texk] Logged in a2 XAPPLEPUSHSERVICE aps-version 2 aps-account-id 0715A26B-CA09-4730-A419-793000CA982E aps-device-token 2918390218931890821908309283098109381029309829018310983092892829 aps-subtopic com.apple.mobilemail mailboxes (INBOX Notes)

  • XAPPLEPUSHSERVICE "aps-version" "1" "aps-topic" "com.apple.mail.XServer.ce18a160-37f5-4643-9d93-89c1dcd82676"
    a2 OK XAPPLEPUSHSERVICE completed.
    a3 LOGOUT
  • BYE Logging out
    a3 OK Logout completed.`

Dovecot 2.0.19 with dovecot-xaps-plugin

`* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN] Dovecot ready.
a1 LOGIN stefan xxx
a1 OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS XAPPLEPUSHSERVICE] Logged in
a2 XAPPLEPUSHSERVICE aps-version 2 aps-account-id 0715A26B-CA09-4730-A419-793000CA982E aps-device-token 2918390218931890821908309283098109381029309829018310983092892829 aps-subtopic com.apple.mobilemail mailboxes (INBOX Notes)

  • XAPPLEPUSHSERVICE aps-version "2" aps-topic "com.apple.mail.XServer.ce18a160-37f5-4643-9d93-89c1dcd82676
    "
    a2 OK XAPPLEPUSHSERVICE Registration successful.
    a3 LOGOUT
  • BYE Logging out
    a3 OK Logout completed.`

FIXED! Error: write(/tmp/xapsd.sock) failed: Broken pipe

Hello,

i installed all and deamon seems to working fine, but in maillog i get these messages:

imap([email protected]): Error: write(/tmp/xapsd.sock) failed: Broken pipe

and when getting new mail these:

dovecot: lda([email protected]): Debug: xaps_plugin_init
dovecot: lda([email protected]): Debug: xaps_transaction_begin
dovecot: lda([email protected]): Debug: xaps_transaction_begin
dovecot: lda([email protected]): Debug: xaps_save_finish
dovecot: lda([email protected]): Debug: xaps_transaction_commit
dovecot: lda([email protected]): Error: write(/tmp/xapsd.sock) failed: Broken pipe
dovecot: lda([email protected]): Error: cannot notify
dovecot: lda([email protected]): sieve: msgid=<[email protected]>: stored mail into mailbox 'INBOX'
dovecot: lda([email protected]): Debug: xaps_plugin_deinit

i run the deamon in an python virtualenv because i need older version of modules for an old apple calendarserver installation.

here output from daemon:

2014-10-22 16:05:29+0200 [-] Log opened.
2014-10-22 16:05:29+0200 [-] twistd 14.0.0 (/usr/local/src/dovecot-xaps-daemon-master/foo/bin/python 2.6.8) starting up.
2014-10-22 16:05:29+0200 [-] reactor class: twisted.internet.epollreactor.EPollReactor.
2014-10-22 16:05:29+0200 [-] XAPSFactory starting on '/tmp/xapsd.sock'
2014-10-22 16:05:29+0200 [-] Starting factory <xaps.XAPSFactory instance at 0xa58ae2c>
2014-10-22 16:05:29+0200 [-] Starting factory <apns.APNSClientFactory instance at 0x96a7aec>
2014-10-22 16:05:29+0200 [-] APNSClientFactory.startedConnecting
2014-10-22 16:05:59+0200 [-] APNSClientFactory.clientConnectionFailed
2014-10-22 16:05:59+0200 [-] <twisted.internet.tcp.Connector instance at 0x9a1f0ac> will retry in 3 seconds
2014-10-22 16:05:59+0200 [-] Stopping factory <apns.APNSClientFactory instance at 0x96a7aec>
2014-10-22 16:06:03+0200 [-] Starting factory <apns.APNSClientFactory instance at 0x96a7aec>
2014-10-22 16:06:03+0200 [-] APNSClientFactory.startedConnecting
2014-10-22 16:06:33+0200 [-] APNSClientFactory.clientConnectionFailed
2014-10-22 16:06:33+0200 [-] <twisted.internet.tcp.Connector instance at 0x9a1f0ac> will retry in 8 seconds
2014-10-22 16:06:33+0200 [-] Stopping factory <apns.APNSClientFactory instance at 0x96a7aec>
2014-10-22 16:06:42+0200 [-] Starting factory <apns.APNSClientFactory instance at 0x96a7aec>
2014-10-22 16:06:42+0200 [-] APNSClientFactory.startedConnecting
2014-10-22 16:07:12+0200 [-] APNSClientFactory.clientConnectionFailed
2014-10-22 16:07:12+0200 [-] <twisted.internet.tcp.Connector instance at 0x9a1f0ac> will retry in 19 seconds
2014-10-22 16:07:12+0200 [-] Stopping factory <apns.APNSClientFactory instance at 0x96a7aec>
2014-10-22 16:07:31+0200 [-] Starting factory <apns.APNSClientFactory instance at 0x96a7aec>
2014-10-22 16:07:31+0200 [-] APNSClientFactory.startedConnecting
2014-10-22 16:07:57+0200 [XAPSProtocol,0,] lineReceived: REGISTER aps-account-id="AE60FB89-31F6-4A90-9A3E-66B0802E6797" aps-device-token="6164381EB6E9A4CC36308A23A05A35C29C5363648452B6ACD79B3FDB3741D19A" aps-subtopic="com.apple.mobilemail" dovecot-username="[email protected]" dovecot-mailboxes=("INBOX","INBOX.Sent")
2014-10-22 16:07:57+0200 [XAPSProtocol,0,] Command(name='REGISTER', args={'aps-account-id': 'AE60FB89-31F6-4A90-9A3E-66B0802E6797', 'aps-device-token': '6164381EB6E9A4CC36308A23A05A35C29C5363648452B6ACD79B3FDB3741D19A', 'dovecot-mailboxes': ['INBOX', 'INBOX.Sent'], 'dovecot-username': '[email protected]', 'aps-subtopic': 'com.apple.mobilemail'})
2014-10-22 16:07:57+0200 [XAPSProtocol,0,] handleRegister: Command(name='REGISTER', args={'aps-account-id': 'AE60FB89-31F6-4A90-9A3E-66B0802E6797', 'aps-device-token': '6164381EB6E9A4CC36308A23A05A35C29C5363648452B6ACD79B3FDB3741D19A', 'dovecot-mailboxes': ['INBOX', 'INBOX.Sent'], 'dovecot-username': '[email protected]', 'aps-subtopic': 'com.apple.mobilemail'})
2014-10-22 16:07:57+0200 [XAPSProtocol,1,] lineReceived: REGISTER aps-account-id="F1AA61EF-FC51-4231-8AA3-408CA3286200" aps-device-token="6164381EB6E9A4CC36308A23A05A35C29C5363648452B6ACD79B3FDB3741D19A" aps-subtopic="com.apple.mobilemail" dovecot-username="[email protected]" dovecot-mailboxes=("INBOX","INBOX.Sent")
2014-10-22 16:07:57+0200 [XAPSProtocol,1,] Command(name='REGISTER', args={'aps-account-id': 'F1AA61EF-FC51-4231-8AA3-408CA3286200', 'aps-device-token': '6164381EB6E9A4CC36308A23A05A35C29C5363648452B6ACD79B3FDB3741D19A', 'dovecot-mailboxes': ['INBOX', 'INBOX.Sent'], 'dovecot-username': '[email protected]', 'aps-subtopic': 'com.apple.mobilemail'})
2014-10-22 16:07:57+0200 [XAPSProtocol,1,] handleRegister: Command(name='REGISTER', args={'aps-account-id': 'F1AA61EF-FC51-4231-8AA3-408CA3286200', 'aps-device-token': '6164381EB6E9A4CC36308A23A05A35C29C5363648452B6ACD79B3FDB3741D19A', 'dovecot-mailboxes': ['INBOX', 'INBOX.Sent'], 'dovecot-username': '[email protected]', 'aps-subtopic': 'com.apple.mobilemail'})
2014-10-22 16:08:01+0200 [-] APNSClientFactory.clientConnectionFailed
2014-10-22 16:08:01+0200 [-] <twisted.internet.tcp.Connector instance at 0x9a1f0ac> will retry in 62 seconds
2014-10-22 16:08:01+0200 [-] Stopping factory <apns.APNSClientFactory instance at 0x96a7aec>
2014-10-22 16:08:02+0200 [XAPSProtocol,2,] lineReceived: REGISTER aps-account-id="F1AA61EF-FC51-4231-8AA3-408CA3286200" aps-device-token="6164381EB6E9A4CC36308A23A05A35C29C5363648452B6ACD79B3FDB3741D19A" aps-subtopic="com.apple.mobilemail" dovecot-username="[email protected]" dovecot-mailboxes=("INBOX","INBOX.Sent")
2014-10-22 16:08:02+0200 [XAPSProtocol,2,] Command(name='REGISTER', args={'aps-account-id': 'F1AA61EF-FC51-4231-8AA3-408CA3286200', 'aps-device-token': '6164381EB6E9A4CC36308A23A05A35C29C5363648452B6ACD79B3FDB3741D19A', 'dovecot-mailboxes': ['INBOX', 'INBOX.Sent'], 'dovecot-username': '[email protected]', 'aps-subtopic': 'com.apple.mobilemail'})
2014-10-22 16:08:02+0200 [XAPSProtocol,2,] handleRegister: Command(name='REGISTER', args={'aps-account-id': 'F1AA61EF-FC51-4231-8AA3-408CA3286200', 'aps-device-token': '6164381EB6E9A4CC36308A23A05A35C29C5363648452B6ACD79B3FDB3741D19A', 'dovecot-mailboxes': ['INBOX', 'INBOX.Sent'], 'dovecot-username': '[email protected]', 'aps-subtopic': 'com.apple.mobilemail'})
2014-10-22 16:08:03+0200 [XAPSProtocol,3,] lineReceived: REGISTER aps-account-id="AE60FB89-31F6-4A90-9A3E-66B0802E6797" aps-device-token="6164381EB6E9A4CC36308A23A05A35C29C5363648452B6ACD79B3FDB3741D19A" aps-subtopic="com.apple.mobilemail" dovecot-username="[email protected]" dovecot-mailboxes=("INBOX","INBOX.Sent")
2014-10-22 16:08:03+0200 [XAPSProtocol,3,] Command(name='REGISTER', args={'aps-account-id': 'AE60FB89-31F6-4A90-9A3E-66B0802E6797', 'aps-device-token': '6164381EB6E9A4CC36308A23A05A35C29C5363648452B6ACD79B3FDB3741D19A', 'dovecot-mailboxes': ['INBOX', 'INBOX.Sent'], 'dovecot-username': '[email protected]', 'aps-subtopic': 'com.apple.mobilemail'})
2014-10-22 16:08:03+0200 [XAPSProtocol,3,] handleRegister: Command(name='REGISTER', args={'aps-account-id': 'AE60FB89-31F6-4A90-9A3E-66B0802E6797', 'aps-device-token': '6164381EB6E9A4CC36308A23A05A35C29C5363648452B6ACD79B3FDB3741D19A', 'dovecot-mailboxes': ['INBOX', 'INBOX.Sent'], 'dovecot-username': '[email protected]', 'aps-subtopic': 'com.apple.mobilemail'})
2014-10-22 16:09:04+0200 [-] Starting factory <apns.APNSClientFactory instance at 0x96a7aec>
2014-10-22 16:09:04+0200 [-] APNSClientFactory.startedConnecting
2014-10-22 16:09:34+0200 [-] APNSClientFactory.clientConnectionFailed
2014-10-22 16:09:34+0200 [-] <twisted.internet.tcp.Connector instance at 0x9a1f0ac> will retry in 154 seconds
2014-10-22 16:09:34+0200 [-] Stopping factory <apns.APNSClientFactory instance at 0x96a7aec>

Fails to integrate with Dovecot 2.3.0

Hi,

After update dovecot to version 2.3.0, the plugin fails to compile:
The message is:

cc -std=gnu99 -fPIC -shared -Wall -I/usr/include/dovecot -DHAVE_CONFIG_H xaps-plugin.c -o xaps_plugin.so
xaps-plugin.c: In function 'xaps_transaction_begin':
xaps-plugin.c:153:12: error: too few arguments to function 'zbox->super.transaction_begin'
return zbox->super.transaction_begin(box, flags);
^~~~
xaps-plugin.c: In function 'xaps_mailbox_allocated':
xaps-plugin.c:207:30: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
box->v.transaction_begin = xaps_transaction_begin;
^
xaps-plugin.c: In function 'xaps_transaction_begin':
xaps-plugin.c:154:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
gmake: *** [Makefile:43: xaps_plugin.so] Error 1

Any idea? Thanks in advance!

Compiling/Running on macOS?

Is it possible to compile/run this on macOS? With the coming macOS-pocalypse, I'd love to run this plugin on a Mac Mini with Dovecot.

undefined symbol: push_notification_driver_debug

I tried updating to the latest code, and I'm getting the following in my logs:

Error: Couldn't load required plugin /usr/lib/dovecot/modules/imap_xaps_plugin.so: dlopen() failed: /usr/lib/dovecot/modules/imap_xaps_plugin.so: undefined symbol: push_notification_driver_debug

xaps_imap_plugin.so: undefined symbol net_transmit

Hello everyone,
unfortunately, while trying to setup the plugin and daemon I am currently stuck with the xaps IMAP plugin. The daemon is compiled and running, but the user login to dovecot fails with the following error:

dovecot: imap(****@****************.**): Error: Couldn't load required plugin /usr/lib/dovecot/modules/lib25_xaps_imap_plugin.so: dlopen() failed: /usr/lib/dovecot/modules/lib25_xaps_imap_plugin.so: undefined symbol: net_transmit

The net_transmit symbol is referenced in xaps-daemon.c:68. Am I missing packages?
I am running Dovecot 2.3.9.2 (cf2918cac).

Dovecot not advertising new messages to socket

I'm running Dovecot 2.2.18 on Debian 7. I installed both the plugin and the daemon with success.
Dovecot is adding the XAPPLEPUSHSERVICE capability to IMAP and my iOS device is recognising it. Also does the list in ~/xaps.json get filled with devicesId's.

However, when a new email gets sent to Dovecot, it does not call the method to actually send a command over the socket. I enabled loggin on my daemon, and it does not receive a single thing.

My last logs from the daemon:

2015/07/28 18:10:48 [DEBUG] Opening database at /root/xapsd.json
2015/07/28 18:10:48 [DEBUG] Listening on UNIX socket at /var/run/dovecot/xapsd.sock
2015/07/28 18:10:48 [DEBUG] Parsing /root/certificate.pem to obtain APNS Topic
2015/07/28 18:10:48 [DEBUG] Topic is com.apple.mail.XServer.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
2015/07/28 18:10:48 [DEBUG] Creating APNS client to gateway.push.apple.com:2195
2015/07/28 18:10:48 Starting xapsd 1.0b1 on /var/run/dovecot/xapsd.sock

Dovecot plugin config:

protocol imap {
  mail_plugins = $mail_plugins imap_xaps
}

protocol lda {
  mail_plugins = $mail_plugins xaps
}

protocol lmtp {
  mail_plugins = $mail_plugins xaps
}

plugin {
        # Defaults to /var/run/dovecot/xapsd.sock
  xaps_socket = /var/run/dovecot/xapsd.sock
}

The command I'm running:

/usr/local/dovecot-xaps-daemon/bin/xapsd -key=/root/key.pem -certificate=/root/certificate.pem -database=/root/xapsd.json -socket=/var/run/dovecot/xapsd.sock -debug=true

Any thoughts why this might be causing this?

Dovecot 2.2 ostream-unix

Hi, is ostream-unix supported for dovecot <2.3?
I can´t find it in the sources until 2.3rc1. Or do I have to manually merge it?

disabling "debug" log messages?

Hi Guys,

I have been trying to figure out away to stop the unnecessary debug log messages which this plugin seems to produce. I have gone though the code but I can't seem to figure out how to disable the debug messages and they are filling up my logs quickly.

Does anyone know how I can disable these messages? or do I need to "hack" the source code somewhere to do this? if so where?

Kind Regards,

Simon

/var/log/mail.log

Feb  9 22:55:57 mail1 dovecot: lda([email protected]): Debug: xaps_plugin_init
Feb  9 22:55:57 mail1 dovecot: lda([email protected]): Debug: xaps_transaction_begin
Feb  9 22:55:57 mail1 dovecot: lda([email protected]): Debug: xaps_transaction_begin
Feb  9 22:55:57 mail1 dovecot: lda([email protected]): Debug: xaps_save_finish
Feb  9 22:55:57 mail1 dovecot: lda([email protected]): Debug: xaps_transaction_commit
Feb  9 22:55:57 mail1 dovecot: lda([email protected]): sieve: msgid=<[email protected]>: stored mail into mailbox 'INBOX'
Feb  9 22:55:57 mail1 dovecot: lda([email protected]): Debug: xaps_plugin_deinit

Notifications for read/unread?

Hi, I noticed that, since switching from Load to Push, the "new" badge at Mail.app will never go away when I read the new mail on another device.

Is there any way to push notifications for read/unread status changes as well?

Build on Debian Stretch

According to README, Dovecot > 2.2.19 is still supported on master but it doesn't build on stretch (which has 2.2.27).

There are 3 problems AFAICT:

  • The version check around ostream doesn't seem to be working - if i'm reading it right its says major version >= 2 or minor version >= 3. Shouldnt it be something like major > 2 || (major == 2 && minor > ???)

  • The compiler on stretch is being strict about ordering - str_nescape is being used before we define it

  • str_append_max is still called str_append_n on this version of dovecot.

With those changes in place the build completes - will report back on if they actually work.

(This is probably related to #41).

Dovecot > 2.2.19 ostream-unix.h

I'm running Ubuntu 16.04.3 LTS with Dovecot 2.2.22 (fe789d2) and I'm getting xaps-daemon.c:29:26: fatal error: ostream-unix.h: No such file or directory.
It seems ostream-unix was only introduced in dovecot 2.2.31?

Posting and configs

I seem to have this working on CentOS 6. I can share my binaries if needed. Some of the configs don't work as expected though. Dovecot does not resolve the $mail_plugins. I had to do it the way I show it below.

protocol imap {
#        mail_plugins = imap_xaps $mail_plugins
    mail_plugins = imap_xaps
}

protocol lda {
#   mail_plugins = xaps $mail_plugins
    mail_plugins = xaps
}

protocol lmtp {
#   mail_plugins = xaps $mail_plugins
        mail_plugins = xaps
}

plugin {
    xaps_socket = /var/run/xapsd/xapsd.sock
}

dovecot crash with this email

Since version 2.3.9, certain mail makes lmtp and imap processes crash.
I made shure I had the latest plugin version and recompiled it.

Attached is the anonymized source of the message

Notification before sieve filtering

Perhaps i have a misconfiguration, but i can't find it.
On my server i get notifications with xaps for mails sorted later by sieve filters.
Can anyone help me to get xaps after sieve?

Log-output:

Apr 13 14:06:32 mymailserver postfix/pickup[2129]: AD77E44DDA: uid=0 from=<[email protected]>
Apr 13 14:06:32 mymailserver postfix/cleanup[3922]: AD77E44DDA: message-id=<[email protected]>
Apr 13 14:06:32 mymailserver postfix/qmgr[31901]: AD77E44DDA: from=<[email protected]>, size=600, nrcpt=1 (queue active)
Apr 13 14:06:48 mymailserver postfix/smtpd[3940]: connect from unknown[127.0.0.1]
Apr 13 14:06:48 mymailserver postfix/smtpd[3940]: 4E12136A29: client=unknown[127.0.0.1]
Apr 13 14:06:48 mymailserver postfix/cleanup[3922]: 4E12136A29: message-id=<[email protected]>
Apr 13 14:06:48 mymailserver postfix/qmgr[31901]: 4E12136A29: from=<[email protected]>, size=1304, nrcpt=1 (queue active)
Apr 13 14:06:48 mymailserver postfix/smtpd[3940]: disconnect from unknown[127.0.0.1] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5
Apr 13 14:06:48 mymailserver amavis[32217]: (32217-03) Passed CLEAN {RelayedInbound}, [127.0.0.1] <[email protected]> -> <[email protected]>, Message-ID: <[email protected]>, mail_id: 7qyRJxAQHa1S, Hits: -1.901, size: 599, queued_as: 4E12136A29, 15513 ms
Apr 13 14:06:48 mymailserver postfix/lmtp[3928]: AD77E44DDA: to=<[email protected]>, relay=127.0.0.1[127.0.0.1]:10024, delay=16, delays=0.14/0.02/0.02/16, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as 4E12136A29)
Apr 13 14:06:48 mymailserver postfix/qmgr[31901]: AD77E44DDA: removed
Apr 13 14:06:48 mymailserver dovecot: lda([email protected]): Debug: xaps_plugin_init
Apr 13 14:06:48 mymailserver dovecot: lda([email protected]): Debug: xaps_transaction_begin
Apr 13 14:06:48 mymailserver dovecot: lda([email protected]): Debug: xaps_transaction_begin
Apr 13 14:06:48 mymailserver dovecot: lda([email protected]): Debug: xaps_save_finish
Apr 13 14:06:48 mymailserver dovecot: lda([email protected]): Debug: xaps_transaction_commit
Apr 13 14:06:48 mymailserver dovecot: lda([email protected]): sieve: msgid=<[email protected]>: stored mail into mailbox 'INBOX'
Apr 13 14:06:48 mymailserver dovecot: lda: Debug: xaps_plugin_deinit
Apr 13 14:06:48 mymailserver postfix/pipe[3945]: 4E12136A29: to=<[email protected]>, relay=dovecot, delay=0.13, delays=0.03/0.03/0/0.06, dsn=2.0.0, status=sent (delivered via dovecot service)
Apr 13 14:06:48 mymailserver postfix/qmgr[31901]: 4E12136A29: removed

dovecot config (snap):

protocols = imap lmtp sieve
protocol lmtp {
  mail_plugins = quota quota sieve xaps
  postmaster_address = [email protected]
}
protocol lda {
  mail_plugins = sieve xaps
}
protocol imap {
  mail_max_userip_connections = 30
  mail_plugins = quota imap_quota antispam imap_xaps
}
protocol sieve {
  mail_max_userip_connections = 30
}

Disable debug loggin

The plugin is pretty verbose, it prints a bunch of stuff that is really debug and not info.

Undefined symbols

Using dovecot-2.2.13, xaps_plugin.so compiles OK, but compilation of imap_xaps_plugin.so fails with a slew of undefined symbols

Undefined symbols for architecture x86_64:
  "_client_read_args", referenced from:
      _cmd_xapplepushservice in imap-xaps-plugin-33a6ca.o
  "_client_send_command_error", referenced from:
      _cmd_xapplepushservice in imap-xaps-plugin-33a6ca.o
  "_client_send_line", referenced from:
      _cmd_xapplepushservice in imap-xaps-plugin-33a6ca.o
  "_client_send_tagline", referenced from:
      _cmd_xapplepushservice in imap-xaps-plugin-33a6ca.o
  "_command_register", referenced from:
      _imap_xaps_plugin_init in imap-xaps-plugin-33a6ca.o
  "_command_unregister", referenced from:
      _imap_xaps_plugin_deinit in imap-xaps-plugin-33a6ca.o
  "_imap_client_created_hook_set", referenced from:
      _imap_xaps_plugin_init in imap-xaps-plugin-33a6ca.o
      _imap_xaps_plugin_deinit in imap-xaps-plugin-33a6ca.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [imap_xaps_plugin.so] Error 1

Follow debug settings from dovecot (minor)

Can the plugin code be updated to reflect dovecot's debug/verbose/info configurations before add debug messages at the logs, instead of blindly calling i_debug functions at certain steps?

Lower CMake version

There seems to be no reason to require CMake 3.7 instead of CMake 3.6, so could you consider lowering the bar there?

xapsd crashes

Hi Stefan,

first of all -- thanks a lot for your work with xapsd! Looks like this is the only existing solution for iOS push -- great.

We have some heavy loaded systems and there xapsd dies from time to time. Could you help us to debug the reason for that?

We're using Dovecot 2.2.29 and 2.2.31 on Debian 8.8.

root@imap:~# service dovecot-xaps status
● dovecot-xaps.service - Dovecot XAPS Daemon
Loaded: loaded (/lib/systemd/system/dovecot-xaps.service; enabled)
Active: failed (Result: exit-code) since Sa 2017-07-01 17:14:42 CEST; 8min ago
Process: 118082 ExecStart=/usr/sbin/xapsd -key=/etc/xapsd/key.pem -certificate=/etc/xapsd/certificate.pem -database=/var/lib/xapsd/xapsd.json -socket=/var/run/xapsd/xapsd.sock (code=exited, status=2)
Main PID: 118082 (code=exited, status=2)

Jul 01 17:14:42 imap xapsd[118082]: main.(*Database).write(0xc42000c400, 0xc420237e88, 0xc420ae1d08)
Jul 01 17:14:42 imap xapsd[118082]: /root/build/dovecot-xaps-daemon/src/cmd/xapsd/database.go:93 +0x62
Jul 01 17:14:42 imap xapsd[118082]: main.(*Database).addRegistration(0xc42000c400, 0xc420ad80c9, 0x1a, 0xc420ad8019, ...2, ...)
Jul 01 17:14:42 imap xapsd[118082]: /root/build/dovecot-xaps-daemon/src/cmd/xapsd/database.go:115 +0x232
Jul 01 17:14:42 imap xapsd[118082]: main.handleRegister(0x6f2ce0, 0xc420ac8000, 0xc420ad8000, 0x8, 0xc420ad4030, 0xc4..., 0x3b)
Jul 01 17:14:42 imap xapsd[118082]: /root/build/dovecot-xaps-daemon/src/cmd/xapsd/xapsd.go:303 +0x2f7
Jul 01 17:14:42 imap xapsd[118082]: main.handleRequest(0x6f2ce0, 0xc420ac8000, 0xc42015f640, 0xc42000c400, 0xc420144fc0, 0x3b)
Jul 01 17:14:42 imap xapsd[118082]: /root/build/dovecot-xaps-daemon/src/cmd/xapsd/xapsd.go:242 +0x388
Jul 01 17:14:42 imap xapsd[118082]: created by main.main
Jul 01 17:14:42 imap xapsd[118082]: /root/build/dovecot-xaps-daemon/src/cmd/xapsd/xapsd.go:222 +0x498
Hint: Some lines were ellipsized, use -l to show in full.

Updates on Flags don't trigger push

If the client changes a message flag from "unread" to "read" the client will do an update on the flags by IMAP.

Looks like this event isn't captured from xaps-plugin.

The clients don't get an push notification, so they don't update their cache and the message stays marked as unread untill the next manual sync is done.

Ubuntu 18.04 build issue

I'm getting an error building, I followed the steps.
dovecot version 2.2.33.2 (d6601f4ec)
dovecot-xaps-plugin/xaps-daemon.c:196:13: error: conflicting types for ‘str_nescape’
const char *str_nescape(const void *str, size_t len)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.