A simple approach would be to just run an IMAP server. For receiving you use a script using POP3 to download newly arrived emails (which is run every 5 minutes for example). If your server is offline, nothing gets lost.
For the sending side you can either use your mail ISP’s SMTP server directly from the client or you install a local relay as a mitm to the ISP’s SMTP.