mailofly 0.1.0
mailofly: ^0.1.0 copied to clipboard
Official Dart client for the Mailofly REST API (one-off compose, contacts, templates, campaigns, and more).
mailofly #
Official Dart client for the Mailofly REST API.
Requirements #
- Dart 3.0 or newer (Flutter compatible).
Install #
dependencies:
mailofly: ^0.1.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 accounts = await client.accounts.list();
print(accounts['data']);
await client.compose.send({
'account_key': 'acc_…',
'subject': 'Hi {{first_name}}',
'body': '<p>Thanks for signing up.</p>',
'recipients': {
'emails': ['you@example.com'],
},
'variables': {'first_name': 'Alex'},
});
} 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 |
|---|---|
| Accounts | client.accounts.list(), create, get, update, delete |
| 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 |
| Compose | client.compose.send({...}) |
| Mail logs | client.mailLogs.list(page: 1, pageSize: 20, status: 'sent') |
Request/response JSON matches /api/v1.
Custom base URL & HTTP client #
final client = Mailofly(
apiKey: 'mf_live_…',
baseUrl: 'https://www.mailofly.com',
httpClient: myClient, // optional; default closes when you call client.close()
);
License #
MIT