#
Dart SDK
A Dart SDK for sending and receiving emails over the Nostr protocol using NIP-59 gift-wrapped messages.
#
Installation
dart pub add nostr_mail
Or add to your pubspec.yaml:
dependencies:
nostr_mail: ^1.1.0
#
Features
- Send and receive emails over Nostr
- NIP-59 gift-wrapped encryption
- Automatic bridge resolution for legacy emails
- Local email storage with Sembast
- Real-time inbox streaming
- Historical email sync
#
Quick Start
import 'package:nostr_mail/nostr_mail.dart';
import 'package:ndk/ndk.dart';
import 'package:sembast/sembast_io.dart';
void main() async {
// Initialize NDK with your keys
final ndk = Ndk(NdkConfig(
eventSigner: Bip340EventSigner(privateKey: 'your-hex-key'),
bootstrapRelays: ['wss://relay.damus.io', 'wss://nos.lol'],
));
// Open local database
final db = await databaseFactoryIo.openDatabase('emails.db');
// Create client
final client = NostrMailClient(ndk: ndk, db: db);
// Send an email
await client.send(
to: 'recipient@example.com',
subject: 'Hello from Nostr!',
body: 'This email was sent over the Nostr protocol.',
from: 'me@mybridge.com', // Required for legacy emails
);
// Listen for new emails
await for (final email in client.watchInbox()) {
print('New email from: ${email.from}');
print('Subject: ${email.subject}');
}
}
#
Dependencies
#
Quick Navigation
How to send emails to Nostr and legacy addresses
Watch your inbox and sync historical emails
Email persistence with Sembast
Complete API documentation