-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How use idleStart? #31
Comments
Hey Carlos, thanks for testing enough_mail! You need to listen for events using the imapClient.eventBus.on<ImapEvent>().listen(_onImapEvent); When you start the IDLE mode, do not wait for its return. import 'package:pedantic/pedantic.dart';
[...]
unawaited(imapClient.idleStart()); If you are not using pedantic, then just do not wait for the future: imapClient.idleStart(); Note that you need to have selected a folder before you can start the IDLE mode. When you receive either an void _onImapEvent(ImapEvent event) async {
int messageSequenceId;
if (event is ImapFetchEvent) {
messageSequenceId = event.messageSequenceId;
} else if (event is ImapMessagesExistEvent) {
messageSequenceId = event.newMessagesExists;
}
if (messageSequenceId != null) {
imapClient.idleDone();
var fetchContents =
'(BODY.PEEK[HEADER.FIELDS (message-Id references subject from to cc date content-type content-transfer-encoding)])';
var fetchHeaderResponse =
await imapClient.fetchMessages(messageSequenceId, -1, fetchContents);
if (fetchHeaderResponse.isOkStatus) {
var allMessages = fetchHeaderResponse.result;
for (var mimeMessage in allMessages) {
print('got new message ${mimeMessage.decodeSubject()}');
}
}
unawaited(imapClient.idleStart());
}
} Hope this helps, |
Hi Carlos, have you been able to fetch messages before? Please turn on verbose logging by creating an var imapClient = ImapClient(isLogEnabled: true); In the log you should now see all client and server messages in more detail. It seems to be me that the imap server is not understanding the fetch command, maybe you need to play with the If you can solve it by yourself, please post the solution - and if not please post the log output. |
The high level |
How can use listener when arrived new mails?. I see in log when arrived mails but haven't callback. Help me to implementation idle Start correctly.
The text was updated successfully, but these errors were encountered: