#
API Reference
Complete API documentation for the Nostr Mail SDK.
#
NostrMailClient
Main client for sending and receiving emails.
#
Constructor
NostrMailClient({
required Ndk ndk,
required Database db,
})
#
Methods
#
send()
Send an email to a recipient.
Future<void> send({
required String to,
required String subject,
required String body,
String? from,
String? htmlBody,
bool keepCopy = true,
})
Throws:
NostrMailException- Account not configuredRecipientResolutionException- Cannot resolve recipient
#
watchInbox()
Stream of incoming emails in real-time.
Stream<Email> watchInbox()
Returns: Stream<Email> - Yields emails as they arrive
Throws:
NostrMailException- Account not configured
#
sync()
Fetch and store historical emails from relays.
Future<void> sync()
Throws:
NostrMailException- Account not configured
#
getEmails()
Get cached emails from local storage.
Future<List<Email>> getEmails({
int? limit,
int? offset,
})
Returns: List<Email> - Sorted by date (newest first)
#
getEmail()
Get a single email by ID.
Future<Email?> getEmail(String id)
Returns: Email? - The email or null if not found
#
delete()
Delete an email from local storage.
Future<void> delete(String id)
#
Email
Email model class.
#
Properties
#
Methods
#
toJson()
Map<String, dynamic> toJson()
#
fromJson()
factory Email.fromJson(Map<String, dynamic> json)
#
Exceptions
#
NostrMailException
Base exception for SDK errors.
class NostrMailException implements Exception {
final String message;
NostrMailException(this.message);
}
#
RecipientResolutionException
Thrown when recipient cannot be resolved.
class RecipientResolutionException extends NostrMailException {
final String address;
RecipientResolutionException(this.address);
}
#
Constants
#
Dependencies
dependencies:
ndk: ^0.6.1-dev.4
enough_mail: ^2.1.7
sembast: ^3.8.6
http: ^1.6.0