diff --git a/CHANGELOG.md b/CHANGELOG.md index 88f6dbfe..906543f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.0.26 +- Added high level `MailClient` API +- Downgraded XML dependency to be compatible with flutter_test again +- Fixed `ImapClient`'s `eventBus` registration when this is specified outside of ImapClient. + ## 0.0.25 - Add support to discover email settings using the `Discover` class. diff --git a/README.md b/README.md index c7d1602b..76344706 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,58 @@ -An experimental IMAP, POP3 and SMTP client for Dart developers. +Experimental IMAP, POP3 and SMTP clients for Dart developers. Available under the commercial friendly [MPL Mozilla Public License 2.0](https://www.mozilla.org/en-US/MPL/). -## Usage +## High Level API Usage -A simple usage example: +A simple usage example for using the high level API: + +```dart +import 'dart:io'; +import 'package:enough_mail/enough_mail.dart'; + +String userName = 'user.name'; +String password = 'password'; + +void main() async { + await mailExample(); +} + +Future mailExample() async { + var email = userName + '@domain.com'; + var config = await Discover.discover(email); + var incoming = MailServerConfig() + ..serverConfig = config.preferredIncomingServer + ..authentication = PlainAuthentication(userName, password); + var account = MailAccount() + ..email = email + ..incoming = incoming; + //TODO specify outgoing server configuration + var mailClient = MailClient(account, isLogEnabled: false); + await mailClient.connect(); + var mailboxesResponse = + await mailClient.listMailboxesAsTree(createIntermediate: false); + if (mailboxesResponse.isOkStatus) { + print(mailboxesResponse.result); + await mailClient.selectInbox(); + var fetchResponse = await mailClient.fetchMessages(count: 20); + if (fetchResponse.isOkStatus) { + for (var msg in fetchResponse.result) { + printMessage(msg); + } + } + } + mailClient.eventBus.on().listen((event) { + print('New message at ${DateTime.now()}:'); + printMessage(event.message); + }); + mailClient.startPolling(); +} +``` + +## Low Level Usage + +A simple usage example for using the low level API: ```dart import 'dart:io'; @@ -155,7 +202,7 @@ Add this dependency your pubspec.yaml file: ``` dependencies: - enough_mail: ^0.0.24 + enough_mail: ^0.0.26 ``` The latest version or `enough_mail` is [![enough_mail version](https://img.shields.io/pub/v/enough_mail.svg)](https://pub.dartlang.org/packages/enough_mail). diff --git a/pubspec.yaml b/pubspec.yaml index fa2631de..26c03171 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: enough_mail description: IMAP, POP3 and SMTP clients in pure Dart. Provides low level support for these mail protocols. -version: 0.0.25 +version: 0.0.26 homepage: https://github.com/Enough-Software/enough_mail environment: