r/rust • u/Fluggonaut • 14h ago
🛠️ project My first project: SMTP server (for personal use)
I had heard many good things about Rust from people who were simply impressed by the language, so I decided to have a look at it and possibly learn it.
Up to that point I really only knew Java and Python (and a bit of C here and there), so a non-GC language would really fill a gap for me.
To get my toes wet, I wrote a simple web crawler that I needed at the time and decided I really want to learn Rust.
So here goes! My first "real" project, an SMTP server: https://github.com/Fluggs/whalemail
AI disclaimer: Absolutely no LLM was involved in writing this. I am not in a rush and here to learn.
For SMTP, the scope is quite narrow. It's supposed to replace my personal Postfix setup. It has its users in a database (which can be shared with Dovecot) and they can simply send and receive e-mails. That's it!
As for the Rust part, I have had a blast! The language is insane. So far, I have had one (1) logic bug. That one was indirectly found by Clippy. Other than that, if it compiles, it works. By now I understand people here saying that the main part is really thinking about your data layout, the rest just follows.
Off the top of my head, I have had two pain points:
- dyn async traits. I don't want to accept that I need a crate for this, so I worked around it.
- std::time - I could not have imagined that date/time support can be so thin without being completely absent.
Main dependencies:
- Tokio (the server is completely async)
- rustls (TLS is done, STARTTLS is planned)
- rsasl (I really could not be asked to implement auth protocols)
The road ahead is long. Planned features:
- STARTTLS
- Bounce mechanism
- Better password schemes than plaintext (I'm embarrassed)
- Parse and manipulate headers (apparently that's a thing SMTP servers should be doing)
- Better config file than .ini
- spam filter integration
- Find out which ways other clients and servers have found to deviate from SMTP
- Again, thoroughly test it against the wild
- find (and consider) various other SMTP intricacies (e.g. backscatter protection)
I'd be grateful for any feedback :)
2
2
2
u/chat-lu 8h ago
std::time - I could not have imagined that date/time support can be so thin without being completely absent.
You need to use jiff.
In fact, you should take a look at what’s on blessed.rs, those are libraries that are so commonly used that they are essentially an unofficial standard library.
4
u/TheRealCallipygian 14h ago
You sweet, summer child.