Example for doveadm-save using Doveadm HTTP API

KT Walrus kevin at my.walr.us
Wed May 10 18:26:27 EEST 2017


> 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/v1

Thanks. 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


More information about the dovecot mailing list