Skip to content

Commit

Permalink
release v2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-virkus committed May 22, 2022
1 parent 19bd248 commit b0ebae1
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 22 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 2.0.1
* Thanks to [yarsort](https://github.com/yarsort) resolved various POP3 bugs.
* Interpret mime messages with an (invalid) 2-digit year as coming from the current millennium.


# 2.0.0
Improvements and fixes:
* Thanks to [matthiasn](https://github.com/matthiasn) the date parsing/generation on west of greenwich timezones now works properly.
Expand Down
52 changes: 34 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Add this dependency your pubspec.yaml file:

```
dependencies:
enough_mail: ^1.3.6
enough_mail: ^2.0.0
```
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).

Expand Down Expand Up @@ -40,10 +40,11 @@ Future<void> mailExample() async {
final config = await Discover.discover(email);
if (config == null) {
// note that you can also directly create an account when
// you cannot autodiscover the settings:
// Compare [MailAccount.fromManualSettings] and [MailAccount.fromManualSettingsWithAuth]
// methods for details
print('Unable to autodiscover settings for $email');
// you cannot auto-discover the settings:
// Compare the [MailAccount.fromManualSettings]
// and [MailAccount.fromManualSettingsWithAuth]
// methods for details.
print('Unable to auto-discover settings for $email');
return;
}
print('connecting to ${config.displayName}.');
Expand All @@ -58,14 +59,24 @@ Future<void> mailExample() async {
print(mailboxes);
await mailClient.selectInbox();
final messages = await mailClient.fetchMessages(count: 20);
for (final msg in messages) {
printMessage(msg);
}
messages.forEach(printMessage);
mailClient.eventBus.on<MailLoadEvent>().listen((event) {
print('New message at ${DateTime.now()}:');
printMessage(event.message);
});
await mailClient.startPolling();
// generate and send email:
final builder = MessageBuilder.prepareMultipartAlternativeMessage()
..from = [MailAddress('My name', '[email protected]')]
..to = [MailAddress('Your name', '[email protected]')]
..subject = 'My first message'
..addTextPlain('hello world.')
..addTextHtml('<p>hello <b>world</b></p>');
final file = File.fromUri(Uri.parse('file://./document.pdf'));
await builder.addFile(file, MediaSubtype.applicationPdf.mediaType);
final mimeMessage = builder.buildMimeMessage();
await mailClient.sendMessage(mimeMessage);
} on MailException catch (e) {
print('High level API failed with $e');
}
Expand Down Expand Up @@ -149,13 +160,21 @@ Future<void> smtpExample() async {
await client.connectToServer(smtpServerHost, smtpServerPort,
isSecure: isSmtpServerSecure);
await client.ehlo();
await client.login('user.name', 'password');
final builder = MessageBuilder.prepareMultipartAlternativeMessage();
builder.from = [MailAddress('My name', '[email protected]')];
builder.to = [MailAddress('Your name', '[email protected]')];
builder.subject = 'My first message';
builder.addTextPlain('hello world.');
builder.addTextHtml('<p>hello <b>world</b></p>');
if (client.serverInfo.supportsAuth(AuthMechanism.plain)) {
await client.authenticate('user.name', 'password', AuthMechanism.plain);
} else if (client.serverInfo.supportsAuth(AuthMechanism.login)) {
await client.authenticate('user.name', 'password', AuthMechanism.login);
} else {
return;
}
final builder = MessageBuilder.prepareMultipartAlternativeMessage()
..from = [MailAddress('My name', '[email protected]')]
..to = [MailAddress('Your name', '[email protected]')]
..subject = 'My first message'
..addTextPlain('hello world.')
..addTextHtml('<p>hello <b>world</b></p>');
final file = File.fromUri(Uri.parse('file://./document.pdf'));
await builder.addFile(file, MediaSubtype.applicationPdf.mediaType);
final mimeMessage = builder.buildMimeMessage();
final sendResponse = await client.sendMessage(mimeMessage);
print('message sent: ${sendResponse.isOkStatus}');
Expand Down Expand Up @@ -209,9 +228,6 @@ void printMessage(MimeMessage message) {
}
```

## Migrating from v0.0.x?
Please [follow the instructions](https://github.com/Enough-Software/enough_mail/migration.md).

## Related Projects
Check out these related projects:
* [enough_mail_html](https://github.com/Enough-Software/enough_mail_html) generates HTML out of a `MimeMessage`.
Expand Down
14 changes: 14 additions & 0 deletions example/enough_mail_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ Future<void> mailExample() async {
printMessage(event.message);
});
await mailClient.startPolling();

// generate and send email:
final builder = MessageBuilder.prepareMultipartAlternativeMessage()
..from = [MailAddress('My name', '[email protected]')]
..to = [MailAddress('Your name', '[email protected]')]
..subject = 'My first message'
..addTextPlain('hello world.')
..addTextHtml('<p>hello <b>world</b></p>');
final file = File.fromUri(Uri.parse('file://./document.pdf'));
await builder.addFile(file, MediaSubtype.applicationPdf.mediaType);
final mimeMessage = builder.buildMimeMessage();
await mailClient.sendMessage(mimeMessage);
} on MailException catch (e) {
print('High level API failed with $e');
}
Expand Down Expand Up @@ -124,6 +136,8 @@ Future<void> smtpExample() async {
..subject = 'My first message'
..addTextPlain('hello world.')
..addTextHtml('<p>hello <b>world</b></p>');
final file = File.fromUri(Uri.parse('file://./document.pdf'));
await builder.addFile(file, MediaSubtype.applicationPdf.mediaType);
final mimeMessage = builder.buildMimeMessage();
final sendResponse = await client.sendMessage(mimeMessage);
print('message sent: ${sendResponse.isOkStatus}');
Expand Down
6 changes: 2 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
name: enough_mail
description: IMAP, POP3 and SMTP for email developers. Choose between a low level and a high level API for mailing. Parse and generate MIME messages. Discover email settings.
version: 2.0.0
version: 2.0.1
homepage: https://github.com/Enough-Software/enough_mail

environment:
sdk: '>=2.12.0 <3.0.0'

dependencies:
basic_utils: ^4.2.1
basic_utils: ^4.2.2
collection: ^1.16.0
crypto: ^3.0.2
encrypt: ^5.0.0
enough_convert: ^1.3.0
# path: ../enough_convert
enough_serialization: ^1.4.0
#path: ../enough_serialization
event_bus: ^2.0.0
intl: ^0.17.0
pointycastle: ^3.6.0
Expand Down

0 comments on commit b0ebae1

Please sign in to comment.