Ruby Smtp Server
Building an SMTP server in Ruby is extremely simple because most of the building blocks are already available. EventMachine has an SMTP server at https://www.rubydoc.info/gems/eventmachine/EventMachine/Protocols/SmtpServer that you can customize by copying the code snippet from their documentation page and modifying the receive_message
function to store the email somewhere - perhaps in a database.