The following interface is now provided to allow simple web based access to messages/folders. Requires SurgeMail 7.4d-5 or later.
The following functions are supported:
- msg_folders
- msg_items
- msg_get
- msg_del
- msg_move
Each command responds with JSON formatted data. Authentication can be via the web admin account (using basic authentication http protocol) or with user/pass for a specific account.
For security the connecting ip must match g_web_api_ip setting too.
g_web_api_ip "192.168.1.2"
The 'URL' in examples below would be: http://localhost/api/msgs
Examples:
List Folders
URL?cmd=msg_folders&email=test1@book.netwin.co.nz
{"folders" : ["Archives", "Archives/1970", "Archives/1970/Inbox", "Archives/1973", "Archives/2019", "Archives/2019/Inbox", "Archives/2019/Sent", "COMPLETED Stuff", "Done", "Drafts", "INBOX", "new.copy", "new.copy", "newbad", "outloobug", "Sent", "shared", "sorted", "Trash"], "result": "ok" }
List Messages: URL?
cmd=msg_items&email=test1@book.netwin.co.nz&folder=Inbox&from=3423&last=3 {"items" : ["163468", "163469", "163471"], "result": "ok" } Note: from specifies the starting UID, last specifies how many to show in total as a max.
List Messages with headers:
URL?cmd=msg_items&email=test1@book.com&folder=Inbox&headers=to,subject {"items" : [{uid:"163467", subject:"mid 0 testmail message", to:"test1@book.netwin.co.nz"}, {uid:"163468", subject:"mid 0 testmail message", to:"test1@book.netwin.co.nz"}, {uid:"163469", subject:"mid 0 testmail message", to:"test1@book.netwin.co.nz"}, {uid:"163471", subject:"mid 0 testmail message", to:"test1@book.netwin.co.nz"}], "result": "ok" }
Get Message:
URL?cmd=msg_get&email=test1@book.netwin.co.nz&folder=Inbox&uid=163473
Delete Message:
URL?cmd=msg_del&email=test1@book.netwin.co.nz&folder=Inbox&uid=163472 {"result" : "bad", "info" : "uid not found" }
Move Messages to another folder
URL?cmd=msg_move&email=test1@book.com&folder=Inbox&uid=163470&dest=Done
Display folders, authenticate with user/pass of account:
URL?cmd=msg_folders&email=test1@book.netwin.co.nz&user=test1@book.netwin.co.nz&pass=SECRET