{"_id":"56b5220b7719bb1900143055","githubsync":"","user":"5582e90181672a3900bb4fc7","project":"569f9cf6650e1d1900f96b5b","version":{"_id":"569f9cf6650e1d1900f96b5e","project":"569f9cf6650e1d1900f96b5b","__v":12,"createdAt":"2016-01-20T14:43:02.785Z","releaseDate":"2016-01-20T14:43:02.785Z","categories":["569f9cf7650e1d1900f96b5f","56abdd81d4432d1900eed235","56abe0558beeff0d003b8118","56ad2f8b1c09150d00a183a8","56ad4e1cd21f1b0d00fd2f97","56b00ad88f7a4f0d0029dc92","56b2432e9621f20d00efb2bd","56b25826147e900d00d6497a","56b7af2a4b372d2100722c48","56b8c4d938b1070d0028920f","56b8cdab14feef0d0082415d","58599813cf9e112d0032cdab"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"__v":16,"category":{"_id":"56b25826147e900d00d6497a","project":"569f9cf6650e1d1900f96b5b","version":"569f9cf6650e1d1900f96b5e","pages":["56b2583a9621f20d00efb31c","56b25a3965ddf50d0076baa2","56b2738894ab060d0006743c","56b4d1cf5f1cf00d00cc46d7","56b4f4e2b1a8690d00a59369","56b4f6925f1cf00d00cc4704","56b4fa3d5997532100bc6bcc","56b50ba8eed075230097d71e","56b5123585a6922300d1c506","56b51e475997532100bc6c08","56b5220b7719bb1900143055","56b524cc3d5f130d00dad1b8","56b5265b168b5c1700c15996","56b774438fb4420d006a618b","56b78012eb783a0d007894f3","56b78292a6c10c0d00a2d65d","56b7863aeb783a0d007894f8","56b78f68a6c10c0d00a2d66b","56b794566c2a240d0094ae8a","56b7a85dd22adc0d0053f4c2","56b7ac118fb4420d006a61b7"],"__v":21,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-02-03T19:42:30.051Z","from_sync":false,"order":7,"slug":"user-methods","title":"User methods"},"parentDoc":null,"metadata":{"title":"","description":"","image":[]},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-02-05T22:28:27.548Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"examples":{"codes":[]},"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":11,"body":"## Syntax \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n    <credentials object> \\n    \\\"user\\\": <mailbox_name>, \\n    \\\"folder\\\": <folder_name>\\n}\",\n      \"language\": \"perl\",\n      \"name\": \"  \"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Request fields for get_user_messages\"\n}\n[/block]\nThe following fields can be used in the **get_user_messages** method:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Field name\",\n    \"h-1\": \"Obligation\",\n    \"h-2\": \"Definition/Value\",\n    \"0-0\": \"folder\",\n    \"0-1\": \"Optional\",\n    \"0-2\": \"The folder to search for messages. If not specified, the INBOX folder is searched.\",\n    \"1-0\": \"limit\",\n    \"1-1\": \"Optional\",\n    \"1-2\": \"Specify the number of messages to return.\",\n    \"2-0\": \"recent\",\n    \"2-1\": \"Optional\",\n    \"2-2\": \"Orders the results with the most recent listed first. This setting only applies if **limit** is also specified.\",\n    \"3-0\": \"unseen\",\n    \"3-1\": \"Optional\",\n    \"3-2\": \"Return a list of only those messages that have been delivered to the user, but have not yet been displayed in the user's mail client or through Webmail.\",\n    \"4-0\": \"user\",\n    \"4-1\": \"Required\",\n    \"4-2\": \"The user's account name.\"\n  },\n  \"cols\": 3,\n  \"rows\": 5\n}\n[/block]\nSpecifying a combination of** unseen**, **limit**, and **recent** would be useful as a follow-up call to the user_notify method for a Reseller portal, for example, you could check to see if there are new messages, and then fetch the five most recent message headers to display to the end user.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Response fields for get_user_messages\"\n}\n[/block]\nThe following fields may be returned in response to the **get_user_messages**\nmethod:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Field name\",\n    \"h-1\": \"Obligation\",\n    \"h-2\": \"Description/Value\",\n    \"0-0\": \"count\",\n    \"0-1\": \"Returned if **success = true**\",\n    \"0-2\": \"The number of **messages** returned in the messages list.\",\n    \"1-0\": \"error\",\n    \"1-1\": \"Returned if **success = false**\",\n    \"1-2\": \"A text string that explains the error.\",\n    \"2-0\": \"error_number\",\n    \"2-1\": \"Returned if **success = false**\",\n    \"2-2\": \"A number that represents the error.\",\n    \"3-0\": \"messages\",\n    \"3-1\": \"Returned if **success = true**\",\n    \"3-2\": \"A list of the messages in the specified folder. Includes the following information for each message listed:\\n\\n  * **headers**—A hash containing the message headers and their values.\\n\\n  * **id**—the message id. The id number is used by the [move_user_messages](https://api-opensrs-email.readme.io/v1.0/docs/move_user_messages?bypass=8272e34bb5) method.\",\n    \"4-0\": \"success\",\n    \"4-1\": \"Always returned\",\n    \"4-2\": \"Indicates whether the request was successful or not. Allowed values are **true** and **false**.\"\n  },\n  \"cols\": 3,\n  \"rows\": 5\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Examples for get_user_messages\"\n}\n[/block]\n**Request** \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"credentials\\\": {\\n    \\\"user\\\": \\\"domain_admin:::at:::example.com\\\",\\n    \\\"password\\\": \\\"pencil75\\\"\\n  },\\n  \\\"user\\\": \\\"joe_user@example.com\\\",\\n  \\\"folder\\\": \\\"Trash\\\"\\n}\",\n      \"language\": \"perl\",\n      \"name\": \"  \"\n    }\n  ]\n}\n[/block]\n**Response** \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"success\\\": true,\\n  \\\"messages\\\": [\\n    {\\n      \\\"headers\\\": {\\n        \\\"INTERNALDATE\\\": [\\n          1325879547\\n        ],\\n        \\\"content-disposition\\\": [\\n\\t\\t\\t\\t\\t\\\"inline\\\" \\n        ],\\n        \\\"content-type\\\": [\\n          \\\"text/plain; charset=us-ascii\\\"\\n\\t\\t\\t\\t], \\n        \\\"date\\\": [\\n          \\\"Fri Jan  6 19:52:27 2012\\\"\\n        ],\\n        \\\"subject\\\": [\\n          \\\"Welcome!\\\"\\n        ], \\n        \\\"from\\\": [\\n\\t\\t\\t\\t\\t\\\"Mister Manager <mrmanager@example.com>\\\" \\n        ]\\n\\t\\t\\t},\\n\\t\\t\\t\\\"id\\\": \\\"U2FsdGVkX1/1NoyVE6nnFbezjndojMCc+wKwHMv6alN1D6+ANvZ0sJovSQ8wpPPW7Gb0iv Du/6v0fJWAIrR2S0\\\"\\n    }, \\n    {\\n\\t\\t\\t\\\"headers\\\": {\\n  \\t\\t\\t\\\"INTERNALDATE\\\": [\\n    \\t\\t\\t1326918028\\n  \\t\\t],\\n  \\t\\t\\\"content-disposition\\\": [\\n    \\t\\t\\\"inline\\\"\\n  \\t\\t],\\n  \\t\\t\\\"content-type\\\": [\\n    \\t\\t\\\"text/plain; charset=us-ascii\\\"\\n  \\t\\t],\\n  \\t\\t\\\"date\\\": [\\n        \\\"Wed Jan 18 20:20:28 2012\\\"\\n      ],\\n      \\\"subject\\\": [\\n        \\\"Please empty the fridge!\\\"\\n      ],\\n\\t\\t\\t\\\"from\\\": [\\n\\t\\t\\t\\t\\\"Mister Manager <mrmanager@example.com>\\\"\\n\\t\\t\\t] \\n\\t\\t},\\n    \\\"id\\\": \\\"U2FsdGVkX181ebK9176pd1Iyfsn8Cad5r3lJF9Dj/dskhl0kLi4wdf2nC2n/qgGZ16yK/J EOs42nSuEaWgyy/ZG\\n    }, \\n    {\\n\\t\\t\\t\\\"headers\\\": {\\n  \\t\\t\\t\\\"return-path\\\": [\\n    \\t\\t\\t\\\"joey.joe@bigmail.com\\\"\\n  \\t\\t\\t],\\n  \\t\\t\\t\\\"subject\\\": [\\n    \\t\\t\\t\\\"Thought you might find this interesting\\\"\\n\\t\\t\\t\\t], \\n        \\\"date\\\": [\\n    \\t\\t\\t\\\"Wed, 18 Mar 2009 15:17:16 -0400\\\"\\n  \\t\\t\\t],\\n  \\t\\t\\t\\\"domainkey-signature\\\": [\\n          \\\"a=rsa-sha1; c=nofws; d=bigmail.com; s=gamma; h=mime- version:date:message-id:subject:from:to:content-type; b=iTWQ0kqo3VI9vtYLylGLjEFTibCMnQXCnSAJub8G1QwYh6UFQWtsssjA6brVeBsMQm OZ5s7fOD9Tjq5hm52lw2O5VEdM+l8UtxzUIyVbabTbJBinvQlZXuHM1lEhDLJWK+mr6R j5URFTFMsLo1EV38iOQPS+y8g3xSLbZZtkWYs=\\\"\\n        ],\\n        \\\"INTERNALDATE\\\": [\\n          1326918153\\n        ],\\n\\t\\t\\t\\t\\\"content-type\\\": [\\n\\t\\t\\t\\t\\t\\\"multipart/mixed; boundary=0016e64601e61d626b0465698817\\\"\\n\\t\\t\\t\\t],\\n        \\\"to\\\": [\\n          \\\"<joe_user@example.com>\\\"\\n        ],\\n        \\\"dkim-signature\\\": [\\n        \\t\\\"v=1; a=rsa-sha256; c=relaxed/relaxed; d=bigmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message- id:subject :from:to:content-type; bh=alRvlC+CVwx+e7ngmXH4/KHUuXpinJk5JMA1wqoZAss=; b=nyeK2yYuuV0pQrKXdqrPAwO1wskMLNZ9byvxH2IknVuaS2bHHt364lv1FrZQsvVRSk IO8GZi/5GySlUHpQhyUONJhaol/w1/nCZcf/0VAgE5bcWwHSfl99Dks7ymY6Gw82uShz /wwBuhKEijuskGloKojyXEzBo0JHPrGl6Bv7g=\\\"\\n        ], \\n        \\\"from\\\": [\\n\\t\\t\\t\\t\\t\\\"Joseph Joeson <joey.joe@bigmail.com>\\\" \\n          ],\\n        \\t\\\"mime-version\\\": [\\n          \\t\\\"1.0\\\"\\n        \\t],\\n        \\t\\\"received\\\": [\\n          \\t\\\"by 10.220.95.68 with SMTP id \\nc4mr1102844vcn.25.1237403836440; Wed, 18 Mar 2009 12:17:16 -0700 (PDT)\\\"\\n\\t\\t\\t\\t],\\n        \\\"message-id\\\": [\\n\\t\\t\\t\\t\\t\\\"<402aef9e0903181217i69a6b7c6obdc1d88212d7f41c@mail.bigmail.c\\nom>\\\"\\n\\t\\t\\t\\t]\\n\\t\\t\\t},\\n      \\\"id\\\": \\\"U2FsdGVkX18701M4DRzWHCAPojAWZnk/vumzyS5NKi9K8xjM3XA3WGJk3/mrHWl18I12ca /X/rGSnhmwja+Yl4emx\\n    } \\n  ],\\n  \\\"count\\\": 3 \\n}\",\n      \"language\": \"perl\",\n      \"name\": \"  \"\n    }\n  ]\n}\n[/block]","excerpt":"The **get_user_messages** method returns a list of user messages in a specified folder.","slug":"get_user_messages","type":"basic","title":"get_user_messages"}

get_user_messages

The **get_user_messages** method returns a list of user messages in a specified folder.

## Syntax [block:code] { "codes": [ { "code": "{\n <credentials object> \n \"user\": <mailbox_name>, \n \"folder\": <folder_name>\n}", "language": "perl", "name": " " } ] } [/block] [block:api-header] { "type": "basic", "title": "Request fields for get_user_messages" } [/block] The following fields can be used in the **get_user_messages** method: [block:parameters] { "data": { "h-0": "Field name", "h-1": "Obligation", "h-2": "Definition/Value", "0-0": "folder", "0-1": "Optional", "0-2": "The folder to search for messages. If not specified, the INBOX folder is searched.", "1-0": "limit", "1-1": "Optional", "1-2": "Specify the number of messages to return.", "2-0": "recent", "2-1": "Optional", "2-2": "Orders the results with the most recent listed first. This setting only applies if **limit** is also specified.", "3-0": "unseen", "3-1": "Optional", "3-2": "Return a list of only those messages that have been delivered to the user, but have not yet been displayed in the user's mail client or through Webmail.", "4-0": "user", "4-1": "Required", "4-2": "The user's account name." }, "cols": 3, "rows": 5 } [/block] Specifying a combination of** unseen**, **limit**, and **recent** would be useful as a follow-up call to the user_notify method for a Reseller portal, for example, you could check to see if there are new messages, and then fetch the five most recent message headers to display to the end user. [block:api-header] { "type": "basic", "title": "Response fields for get_user_messages" } [/block] The following fields may be returned in response to the **get_user_messages** method: [block:parameters] { "data": { "h-0": "Field name", "h-1": "Obligation", "h-2": "Description/Value", "0-0": "count", "0-1": "Returned if **success = true**", "0-2": "The number of **messages** returned in the messages list.", "1-0": "error", "1-1": "Returned if **success = false**", "1-2": "A text string that explains the error.", "2-0": "error_number", "2-1": "Returned if **success = false**", "2-2": "A number that represents the error.", "3-0": "messages", "3-1": "Returned if **success = true**", "3-2": "A list of the messages in the specified folder. Includes the following information for each message listed:\n\n * **headers**—A hash containing the message headers and their values.\n\n * **id**—the message id. The id number is used by the [move_user_messages](https://api-opensrs-email.readme.io/v1.0/docs/move_user_messages?bypass=8272e34bb5) method.", "4-0": "success", "4-1": "Always returned", "4-2": "Indicates whether the request was successful or not. Allowed values are **true** and **false**." }, "cols": 3, "rows": 5 } [/block] [block:api-header] { "type": "basic", "title": "Examples for get_user_messages" } [/block] **Request** [block:code] { "codes": [ { "code": "{\n \"credentials\": {\n \"user\": \"domain_admin@example.com\",\n \"password\": \"pencil75\"\n },\n \"user\": \"joe_user@example.com\",\n \"folder\": \"Trash\"\n}", "language": "perl", "name": " " } ] } [/block] **Response** [block:code] { "codes": [ { "code": "{\n \"success\": true,\n \"messages\": [\n {\n \"headers\": {\n \"INTERNALDATE\": [\n 1325879547\n ],\n \"content-disposition\": [\n\t\t\t\t\t\"inline\" \n ],\n \"content-type\": [\n \"text/plain; charset=us-ascii\"\n\t\t\t\t], \n \"date\": [\n \"Fri Jan 6 19:52:27 2012\"\n ],\n \"subject\": [\n \"Welcome!\"\n ], \n \"from\": [\n\t\t\t\t\t\"Mister Manager <mrmanager@example.com>\" \n ]\n\t\t\t},\n\t\t\t\"id\": \"U2FsdGVkX1/1NoyVE6nnFbezjndojMCc+wKwHMv6alN1D6+ANvZ0sJovSQ8wpPPW7Gb0iv Du/6v0fJWAIrR2S0\"\n }, \n {\n\t\t\t\"headers\": {\n \t\t\t\"INTERNALDATE\": [\n \t\t\t1326918028\n \t\t],\n \t\t\"content-disposition\": [\n \t\t\"inline\"\n \t\t],\n \t\t\"content-type\": [\n \t\t\"text/plain; charset=us-ascii\"\n \t\t],\n \t\t\"date\": [\n \"Wed Jan 18 20:20:28 2012\"\n ],\n \"subject\": [\n \"Please empty the fridge!\"\n ],\n\t\t\t\"from\": [\n\t\t\t\t\"Mister Manager <mrmanager@example.com>\"\n\t\t\t] \n\t\t},\n \"id\": \"U2FsdGVkX181ebK9176pd1Iyfsn8Cad5r3lJF9Dj/dskhl0kLi4wdf2nC2n/qgGZ16yK/J EOs42nSuEaWgyy/ZG\n }, \n {\n\t\t\t\"headers\": {\n \t\t\t\"return-path\": [\n \t\t\t\"joey.joe@bigmail.com\"\n \t\t\t],\n \t\t\t\"subject\": [\n \t\t\t\"Thought you might find this interesting\"\n\t\t\t\t], \n \"date\": [\n \t\t\t\"Wed, 18 Mar 2009 15:17:16 -0400\"\n \t\t\t],\n \t\t\t\"domainkey-signature\": [\n \"a=rsa-sha1; c=nofws; d=bigmail.com; s=gamma; h=mime- version:date:message-id:subject:from:to:content-type; b=iTWQ0kqo3VI9vtYLylGLjEFTibCMnQXCnSAJub8G1QwYh6UFQWtsssjA6brVeBsMQm OZ5s7fOD9Tjq5hm52lw2O5VEdM+l8UtxzUIyVbabTbJBinvQlZXuHM1lEhDLJWK+mr6R j5URFTFMsLo1EV38iOQPS+y8g3xSLbZZtkWYs=\"\n ],\n \"INTERNALDATE\": [\n 1326918153\n ],\n\t\t\t\t\"content-type\": [\n\t\t\t\t\t\"multipart/mixed; boundary=0016e64601e61d626b0465698817\"\n\t\t\t\t],\n \"to\": [\n \"<joe_user@example.com>\"\n ],\n \"dkim-signature\": [\n \t\"v=1; a=rsa-sha256; c=relaxed/relaxed; d=bigmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message- id:subject :from:to:content-type; bh=alRvlC+CVwx+e7ngmXH4/KHUuXpinJk5JMA1wqoZAss=; b=nyeK2yYuuV0pQrKXdqrPAwO1wskMLNZ9byvxH2IknVuaS2bHHt364lv1FrZQsvVRSk IO8GZi/5GySlUHpQhyUONJhaol/w1/nCZcf/0VAgE5bcWwHSfl99Dks7ymY6Gw82uShz /wwBuhKEijuskGloKojyXEzBo0JHPrGl6Bv7g=\"\n ], \n \"from\": [\n\t\t\t\t\t\"Joseph Joeson <joey.joe@bigmail.com>\" \n ],\n \t\"mime-version\": [\n \t\"1.0\"\n \t],\n \t\"received\": [\n \t\"by 10.220.95.68 with SMTP id \nc4mr1102844vcn.25.1237403836440; Wed, 18 Mar 2009 12:17:16 -0700 (PDT)\"\n\t\t\t\t],\n \"message-id\": [\n\t\t\t\t\t\"<402aef9e0903181217i69a6b7c6obdc1d88212d7f41c@mail.bigmail.c\nom>\"\n\t\t\t\t]\n\t\t\t},\n \"id\": \"U2FsdGVkX18701M4DRzWHCAPojAWZnk/vumzyS5NKi9K8xjM3XA3WGJk3/mrHWl18I12ca /X/rGSnhmwja+Yl4emx\n } \n ],\n \"count\": 3 \n}", "language": "perl", "name": " " } ] } [/block]