I needed a throwaway SMTP and IMAP server and chanced upon Greenmail: an open source, suite of email servers for testing purposes. https://greenmail-mail-test.github.io/greenmail/
I launch it thusly and have an SMTP and IMAP server with in-core storage.
java -Dgreenmail.smtp.hostname=127.0.0.1 -Dgreenmail.smtp.port=3025 -Dgreenmail.imap.hostname=127.0.0.1 -Dgreenmail.imap.port=3143 -Dgreenmail.imaps.hostname=127.0.0.1 -jar greenmail-standalone-1.6.14.jar