mailofly
Official Dart / Flutter client for the Mailofly REST API.
Source of truth: developed in the mailofly monorepo under
packages/dart. This public repo is mirrored automatically on change.
Requirements
- Dart 3.0 or newer (Flutter compatible).
Install
dependencies:
mailofly: ^0.2.0
dart pub add mailofly
Usage
Create a client with your API key from User → API keys:
import 'package:mailofly/mailofly.dart';
Future<void> main() async {
final client = Mailofly(apiKey: 'mf_live_…');
try {
final identities = await client.identities.list();
print(identities['data']);
await client.emails.send(
from: 'Acme <onboarding@example.com>',
to: 'you@example.com',
subject: 'Hello',
html: '<p>Thanks for signing up.</p>',
);
} on MailoflyException catch (e) {
print('${e.statusCode} ${e.error} ${e.message}');
} finally {
client.close();
}
}
Discovery (no API key)
final meta = await Mailofly.discovery();
print(meta['resources']);
Resources
| API | Dart |
|---|---|
| Identities | client.identities.list(), get, update, delete |
| Accounts | (deprecated alias for client.identities) |
| Contacts | client.contacts.list(segmentId: …), create, get, update, delete |
| Templates | client.templates.list(), … |
| Segments | client.segments.list(), … plus client.segments.contacts(id).list/add/remove |
| Campaigns | client.campaigns.list(), …, runs, send |
| Emails | client.emails.send(), sendRaw, get, list, update, cancel |
| Batch | client.batch.send([…]) |
| Compose | client.compose.send(…) (deprecated — use emails) |
| Mail logs | client.mailLogs.list(page: 1, pageSize: 20, status: 'sent') |
Request/response JSON matches /api/v1.
Docs
Releasing
- Bump
versioninpubspec.yaml(andCHANGELOG.md) in the monorepo PR. - Merge to
main/master→ GitHub Action syncs this folder toteamredevs/mailofly-dart. - Publish workflow runs and publishes to pub.flutter-io.cn only when the version is new.
License
MIT