Skip to content

Commit b0ebae1

Browse files
committed
release v2.0.1
1 parent 19bd248 commit b0ebae1

File tree

4 files changed

+55
-22
lines changed

4 files changed

+55
-22
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 2.0.1
2+
* Thanks to [yarsort](https://github.com/yarsort) resolved various POP3 bugs.
3+
* Interpret mime messages with an (invalid) 2-digit year as coming from the current millennium.
4+
5+
16
# 2.0.0
27
Improvements and fixes:
38
* Thanks to [matthiasn](https://github.com/matthiasn) the date parsing/generation on west of greenwich timezones now works properly.

README.md

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Add this dependency your pubspec.yaml file:
99

1010
```
1111
dependencies:
12-
enough_mail: ^1.3.6
12+
enough_mail: ^2.0.0
1313
```
1414
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).
1515

@@ -40,10 +40,11 @@ Future<void> mailExample() async {
4040
final config = await Discover.discover(email);
4141
if (config == null) {
4242
// note that you can also directly create an account when
43-
// you cannot autodiscover the settings:
44-
// Compare [MailAccount.fromManualSettings] and [MailAccount.fromManualSettingsWithAuth]
45-
// methods for details
46-
print('Unable to autodiscover settings for $email');
43+
// you cannot auto-discover the settings:
44+
// Compare the [MailAccount.fromManualSettings]
45+
// and [MailAccount.fromManualSettingsWithAuth]
46+
// methods for details.
47+
print('Unable to auto-discover settings for $email');
4748
return;
4849
}
4950
print('connecting to ${config.displayName}.');
@@ -58,14 +59,24 @@ Future<void> mailExample() async {
5859
print(mailboxes);
5960
await mailClient.selectInbox();
6061
final messages = await mailClient.fetchMessages(count: 20);
61-
for (final msg in messages) {
62-
printMessage(msg);
63-
}
62+
messages.forEach(printMessage);
6463
mailClient.eventBus.on<MailLoadEvent>().listen((event) {
6564
print('New message at ${DateTime.now()}:');
6665
printMessage(event.message);
6766
});
6867
await mailClient.startPolling();
68+
69+
// generate and send email:
70+
final builder = MessageBuilder.prepareMultipartAlternativeMessage()
71+
..from = [MailAddress('My name', 'sender@domain.com')]
72+
..to = [MailAddress('Your name', 'recipient@domain.com')]
73+
..subject = 'My first message'
74+
..addTextPlain('hello world.')
75+
..addTextHtml('<p>hello <b>world</b></p>');
76+
final file = File.fromUri(Uri.parse('file://./document.pdf'));
77+
await builder.addFile(file, MediaSubtype.applicationPdf.mediaType);
78+
final mimeMessage = builder.buildMimeMessage();
79+
await mailClient.sendMessage(mimeMessage);
6980
} on MailException catch (e) {
7081
print('High level API failed with $e');
7182
}
@@ -149,13 +160,21 @@ Future<void> smtpExample() async {
149160
await client.connectToServer(smtpServerHost, smtpServerPort,
150161
isSecure: isSmtpServerSecure);
151162
await client.ehlo();
152-
await client.login('user.name', 'password');
153-
final builder = MessageBuilder.prepareMultipartAlternativeMessage();
154-
builder.from = [MailAddress('My name', 'sender@domain.com')];
155-
builder.to = [MailAddress('Your name', 'recipient@domain.com')];
156-
builder.subject = 'My first message';
157-
builder.addTextPlain('hello world.');
158-
builder.addTextHtml('<p>hello <b>world</b></p>');
163+
if (client.serverInfo.supportsAuth(AuthMechanism.plain)) {
164+
await client.authenticate('user.name', 'password', AuthMechanism.plain);
165+
} else if (client.serverInfo.supportsAuth(AuthMechanism.login)) {
166+
await client.authenticate('user.name', 'password', AuthMechanism.login);
167+
} else {
168+
return;
169+
}
170+
final builder = MessageBuilder.prepareMultipartAlternativeMessage()
171+
..from = [MailAddress('My name', 'sender@domain.com')]
172+
..to = [MailAddress('Your name', 'recipient@domain.com')]
173+
..subject = 'My first message'
174+
..addTextPlain('hello world.')
175+
..addTextHtml('<p>hello <b>world</b></p>');
176+
final file = File.fromUri(Uri.parse('file://./document.pdf'));
177+
await builder.addFile(file, MediaSubtype.applicationPdf.mediaType);
159178
final mimeMessage = builder.buildMimeMessage();
160179
final sendResponse = await client.sendMessage(mimeMessage);
161180
print('message sent: ${sendResponse.isOkStatus}');
@@ -209,9 +228,6 @@ void printMessage(MimeMessage message) {
209228
}
210229
```
211230

212-
## Migrating from v0.0.x?
213-
Please [follow the instructions](https://github.com/Enough-Software/enough_mail/migration.md).
214-
215231
## Related Projects
216232
Check out these related projects:
217233
* [enough_mail_html](https://github.com/Enough-Software/enough_mail_html) generates HTML out of a `MimeMessage`.

example/enough_mail_example.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,18 @@ Future<void> mailExample() async {
7979
printMessage(event.message);
8080
});
8181
await mailClient.startPolling();
82+
83+
// generate and send email:
84+
final builder = MessageBuilder.prepareMultipartAlternativeMessage()
85+
..from = [MailAddress('My name', 'sender@domain.com')]
86+
..to = [MailAddress('Your name', 'recipient@domain.com')]
87+
..subject = 'My first message'
88+
..addTextPlain('hello world.')
89+
..addTextHtml('<p>hello <b>world</b></p>');
90+
final file = File.fromUri(Uri.parse('file://./document.pdf'));
91+
await builder.addFile(file, MediaSubtype.applicationPdf.mediaType);
92+
final mimeMessage = builder.buildMimeMessage();
93+
await mailClient.sendMessage(mimeMessage);
8294
} on MailException catch (e) {
8395
print('High level API failed with $e');
8496
}
@@ -124,6 +136,8 @@ Future<void> smtpExample() async {
124136
..subject = 'My first message'
125137
..addTextPlain('hello world.')
126138
..addTextHtml('<p>hello <b>world</b></p>');
139+
final file = File.fromUri(Uri.parse('file://./document.pdf'));
140+
await builder.addFile(file, MediaSubtype.applicationPdf.mediaType);
127141
final mimeMessage = builder.buildMimeMessage();
128142
final sendResponse = await client.sendMessage(mimeMessage);
129143
print('message sent: ${sendResponse.isOkStatus}');

pubspec.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
name: enough_mail
22
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.
3-
version: 2.0.0
3+
version: 2.0.1
44
homepage: https://github.com/Enough-Software/enough_mail
55

66
environment:
77
sdk: '>=2.12.0 <3.0.0'
88

99
dependencies:
10-
basic_utils: ^4.2.1
10+
basic_utils: ^4.2.2
1111
collection: ^1.16.0
1212
crypto: ^3.0.2
1313
encrypt: ^5.0.0
1414
enough_convert: ^1.3.0
15-
# path: ../enough_convert
1615
enough_serialization: ^1.4.0
17-
#path: ../enough_serialization
1816
event_bus: ^2.0.0
1917
intl: ^0.17.0
2018
pointycastle: ^3.6.0

0 commit comments

Comments
 (0)