symmetry-imap 0.0.3

IMAP client library


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

IMAP for D / SIL

Status - usable alpha

Most functions are implemented but parsing responses needs to be done. Further to that, MIME parsing functionality from another library needs to be integrated. Certificate checking temporarily broken.

Heavily inspired by imapfilter.

import imap;

int main(string[] args)
{
	import std.conv : to;
	import std.stdio : writeln;
	import std.range : back;

	if (args.length < 6)
	{
		import std.stdio: stderr;
		stderr.writeln("imap-example <user> <pass> <server> <port> <mailbox>");
		return -1;
	}

	auto user = args[1];
	auto pass = args[2];
	auto server = args[3];
	auto port = args[4];
	auto mailbox = args[5];

	// PASSWORD is set in IMAP_PASS environmental variable if none set here
	auto login = ImapLogin(user,pass);
	auto imapServer = ImapServer(server,port);

	auto session = Session(imapServer,login);
	session = session.openConnection;
	writeln(session.socket);

	session = session.login;
	writeln(session);
	//writeln(socketSecureWrite(session,"HELLO"));
	//writeln(socketSecureRead(session));


	// Select Inbox
	auto INBOX =Mailbox(mailbox,"/",'/');
	auto result = session.select(INBOX);
	writeln(result);

	// search all messages since 29 Jan 2019 and get UIDs
	auto searchResult = session.search("SINCE 29-Jan-2019");
	writeln(searchResult.value);
	writeln(searchResult.ids);

	// search all messages from GitHub since 29 Jan 2019 and get UIDs
	searchResult = session.search(`SINCE 29-Jan-2019 FROM "GitHub"`);
	writeln(searchResult.value);

	// fetch one of the messages from above
	auto messageResult = session.fetchText(searchResult.ids.back.to!string);
	writeln(messageResult.value);

	// just fetch the fields we care about
	auto fieldsResult = session.fetchFields(searchResult.ids.back.to!string,"FROM TO");
	writeln(fieldsResult.value);
	return 0;
}
Dependencies:
openssl
Versions:
0.2.0 2022-Oct-19
0.1.20 2022-Sep-08
0.1.19 2022-Jun-07
0.1.18 2022-Jan-11
0.1.17 2021-Dec-30
Show all 39 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 1 downloads this month

  • 87341 downloads total

Score:
0.5
Short URL:
symmetry-imap.dub.pm