This package is a simple but complete mail.gw api wrapper, you can use this to save and manage your accounts, as well read all your temporary emails.
See in the example folder
A static class which is mainly needed for storing, creating and loading accounts, you can load all accounts in a session by saving them with getAuths and loading them with loadAuths
To create an account you just need to use the MailGw.register method.
Params
-
randomStringLength: will be used to generate a random password and/or username if not provided (10 is the default length)
-
username: address' username ([email protected], here, abcdqwerty is the username)
-
password: account's password
-
domain: address' domain, (like @mail.gw, must be Domain class), if not provided, a random one will be provided.
await MailGw.register(password: 'ah yes password');
Returns the Future<GWAccount>
instance (Must be awaited as above!)
You can load an account by using the MailGw.login method
If you provide the id and it is present in the saved accounts it will return the saved account instance (Useful if you don't want to make another api request)
If you don't, and you provide address and password it will retrieve the account from the api's
If nothing is provided/the provided parameters are not valid and elseNew is true a new account will be returned (Default true)
If nothing is provided and elseNew is false, throws MailError with code -1 (Invalid arguments)
String id, address, and password
: Account's id, address and password.DateTime createdAt
: The time when the account was createdDateTime updatedAt
: The last time when the account messages were updatedbool isDeleted
: Tells whenever the account is deletedbool isDisabled
: Tells whenever the account is disabledint quota
: How many bytes can be stored in the messagesint used
: How many bytes are used from the quota
You can use
await account.getMessages();
Returns Future<List<Message>>
(Must be awaited as above!)
You can update the account instance (updatedAt, quota and used) by using:
await account.update();
Returns Future<GWAccount>
(Must be awaited as above!)
You can do so by doing
await account.delete()
Returns Future<bool>
(Must be awaited as above!)
ACHTUNG: Be careful to not use the account after it has been deleted, or else errors will be thrown anytime you will try to use account's methods (Same thing for account's messages)
Only access members!
You can do so by using
account.messages.listen((){})
account.messages returns a stream of Messages
-
String
id: The unique identifier of the message (MailGw DB). -
String
accountId: The unique identifier of the account. -
String
msgid: The unique identifier of the message (Global, both the sender service and MailGw will know this). -
String
intro: The introduction of the message. -
Map<String, dynamic>
from: The sender of the message. -
List<Map<String, dynamic>>
to: The recipients of the message. -
List<String>
cc: The carbon copy recipients of the message. -
List<String>
bcc: The blind carbon copy recipients of the message. -
String
subject: The subject of the message. -
bool
seen: Whether the message has been seen. -
bool
flagged: Whether the message has been flagged. -
bool
isDeleted: Whether the message has been deleted. -
List<String>
verifications: The verifications of the message. -
bool
retention: If the message has arrived -
DateTime
retentionDate: The date of the message retention. -
String
text: The text of the message. -
List<String>
html: The HTML of the message. -
bool
hasAttachments: Whether the message has attachments. -
List<GWAttachment>
attachments: List of the message. -
int
size: The size of the message. -
String
url: The downloadUrl of the message. -
DateTime
createdAt: The date of the message creation. -
DateTime
updatedAt: When the message was seen
As simple as:
await message.download();
Returns Future<MessageSource>
(Must be awaited as above!)
Simply:
await message.delete();
Returns Future<bool>
(Must be awaited as above!)
You can do so by:
await message.seen();
Returns Future<bool>
(Must be awaited as above!)
-
String
id: Domain's id -
String
domain: T he domain (example: @mailgw.com) -
bool
isActive: If the domain is active -
DateTime
createdAt: When the domain was created -
DateTime
updatedAt: When the domain was updated
You can do so by:
await Domain.domains;
Returns Future<List<Domain>>
(Must be awaited as above!)