I could use an example of how to use curl to save a new message to a user?s INBOX using the Doveadm HTTP API. https://wiki2.dovecot.org/Design/DoveadmProtocol/HTTP <https://wiki2.dovecot.org/Design/DoveadmProtocol/HTTP> Do I really use the -d option and inline the entire new message in the command-line? Or, should I create a temporary .json file with the message wrapped in JSON and pass this filename to the -d option? Does anyone have a PHP class that abstracts the HTTP API commands? I?ve been using the Roundcube Framework to deliver new messages by IMAP, but I?m experimenting whether the Doveadm HTTP API might be a better solution. I eventually want my PHP code to do full administration of my users mailboxes. I was planning on using Sieve pipe PHP scripts in conjunction with IMAP to do full admin on mailboxes (as they receive new messages or change a flag, I would trigger maintenance on the mailbox such as deleting or moving to the trash old messages or filing a copy of a new message in a folder). Finally, is the Doveadm HTTP API stable enough to use in production? It seems like the documentation is rather minimal. Can this interface really be used for new message delivery instead of LMTP in production? Or, is this a bad idea to combine mailbox administration with new message delivery? Does anyone here use the Doveadm HTTP API in production? Kevin
> On 10 May 2017, at 14.57, KT Walrus <kevin at my.walr.us> wrote: > > I could use an example of how to use curl to save a new message to a user?s INBOX using the Doveadm HTTP API. >Here you go: doveadm mailbox save parameters: { "command": "save", "parameters": [ { "name": "allUsers", "type": "boolean" }, { "name": "socketPath", "type": "string" }, { "name": "user", "type": "string" }, { "name": "userFile", "type": "string" }, { "name": "mailbox", "type": "string" }, { "name": "file", "type": "string" } ] } example: [ [ "save", { "file": "From: Joulu Pukki <joulu.pukki at korvatunturi.fi>\nSubject: plaa\n\nmail body\n", "mailbox": "INBOX/myfoldertoo", "user": "samik" }, "bb" ] ] # curl -v -X POST -u doveadm:hellodoveadm -H "Content-Type: application/json" -d '[["save",{"user":"samik","mailbox":"INBOX/myfoldertoo","file":"From: Joulu Pukki <joulu.pukki at korvatunturi.fi>\nSubject: plaa\n\nmail body\n"},"bb"]]' http://localhost:8080/doveadm/v1> Does anyone here use the Doveadm HTTP API in production?I know many. Sami
> On May 10, 2017, at 11:06 AM, Sami Ketola <sami.ketola at dovecot.fi> wrote: > > >> On 10 May 2017, at 14.57, KT Walrus <kevin at my.walr.us> wrote: >> >> I could use an example of how to use curl to save a new message to a user?s INBOX using the Doveadm HTTP API. >> > > Here you go: > > doveadm mailbox save > > parameters: > > { > "command": "save", > "parameters": [ > { > "name": "allUsers", > "type": "boolean" > }, > { > "name": "socketPath", > "type": "string" > }, > { > "name": "user", > "type": "string" > }, > { > "name": "userFile", > "type": "string" > }, > { > "name": "mailbox", > "type": "string" > }, > { > "name": "file", > "type": "string" > } > ] > } > > example: > > [ > [ > "save", > { > "file": "From: Joulu Pukki <joulu.pukki at korvatunturi.fi>\nSubject: plaa\n\nmail body\n", > "mailbox": "INBOX/myfoldertoo", > "user": "samik" > }, > "bb" > ] > ] > > # curl -v -X POST -u doveadm:hellodoveadm -H "Content-Type: application/json" -d '[["save",{"user":"samik","mailbox":"INBOX/myfoldertoo","file":"From: Joulu Pukki <joulu.pukki at korvatunturi.fi>\nSubject: plaa\n\nmail body\n"},"bb"]]' http://localhost:8080/doveadm/v1Thanks. I worry that by inlining the entire message in the curl command, the message might exceed some limits on how long a command can be. Some of my messages are up to 20MBs with the attachments and 1MB messages are very common. I also worry about the raw message having unescaped quotes in the message messing up to actual storage of the message in the INBOX. Are HTML mail messages encoded to be safe to enclose in quotations? Or, should I encode the entire mail message and trust that Dovecot can handle decoding the message in the back end? I figure that it would be better to put the message in a file and include it some way as part of the HTTP request data. But, does the doveadm HTTP server handle 20MB requests in a single HTTP request? Probably, it does, but I know I had to configure MySQL to take large SQL queries and they really recommend that large files be broken up into chunks and stored with multiple queries (especially for replication). I?ll probably implement message delivery in PHP using a class that can safely post a large file in an HTTP request, so I won?t really be using curl directly at a bash command line. Do you know of any PHP class for the Doveadm HTTP API that I might use? Kevin