Skip to content

Commit f881e50

Browse files
author
Brno Sartori
committed
teste
1 parent cc8eee9 commit f881e50

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,17 @@ client.createMailbox('INBOX/Foo').then(() => { ... });
232232
// Do the same on a server where the personal namespace is ''
233233
client.createMailbox('Foo').then(() => { ... });
234234
```
235+
## Delete mailbox
236+
237+
Delete a folder with the given path with `deleteMailbox(path)`, automatically handling utf-7 encoding.
238+
239+
Command: [DELETE](http://tools.ietf.org/html/rfc3501#section-6.3.4)
240+
241+
Example
242+
243+
```javascript
244+
client.deleteMailbox('Foo').then(() => { ... });
245+
```
235246

236247
## Select mailbox
237248

src/client.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,27 @@ export default class Client {
359359
}
360360
}
361361

362+
/**
363+
* Delete a mailbox with the given path.
364+
*
365+
* DELETE details:
366+
* https://tools.ietf.org/html/rfc3501#section-6.3.4
367+
*
368+
* @param {String} path
369+
* The path of the mailbox you would like to delete. This method will
370+
* handle utf7 encoding for you.
371+
* @returns {Promise}
372+
* Promise resolves if mailbox was deleted.
373+
*/
374+
async createMailbox (path) {
375+
this.logger.debug('Deleting mailbox', path, '...')
376+
try {
377+
await this.exec({ command: 'DELETE', attributes: [imapEncode(path)] })
378+
} catch (err) {
379+
throw err
380+
}
381+
}
382+
362383
/**
363384
* Runs FETCH command
364385
*

0 commit comments

Comments
 (0)