We have all heard of (Neo)Mutt when it comes to managing e-mail in the terminal right? What would you do if I told you there is an even better and more UNIX way to manage mail on the terminal? Well there is and it's called [mblaze](https://github.com/leahneukirchen/mblaze).
<!--more-->
In this post I will explain to you how to setup mblaze for managing your email, but for that we will 2 more additional software to manage our mail with mblaze. [OpenSMTPD](https://www.opensmtpd.org/) the openbsd fast mail server for getting local mail from services like crontab and sending mail with, and [isync](https://isync.sourceforge.io/) for downloading our mail from our remote server's either selfhosted or gmail.
# 1. OpenSMTPD
First we will setup OpenSMTP for local mail, and we will also relay's that allow us to send e-mail from our selfhosted or gmail mail server's for example. Make sure to install opensmtpd from your package maanager.
> Edit `/etc/smtpd/smtpd.conf`
```conf
table aliases file:/etc/mail/aliases
table credentials file:/etc/mail/credentials
listen on 127.0.0.1
action "local_mail" maildir "/home/%{user.username}/.local/share/Maildir/local" alias <aliases>
match mail-from "selfhost@domain.com" for any action outbound_selfhost
match mail-from "username@gmail.com" for any action outbound_gmail
```
Next you will need to update aliases in file /etc/mail/aliases under the comment `# Well-known aliases -- these should be filled in!` to your main user account on your system.
Now we will also setup the passwords in the `/etc/mail/credentials`, Note for gmail you will need to setup app password for it to be usable with this method and enable smtp in gmail.
```conf
selfhost selfhost:selfhost_password
gmail gmail:gmail_password
```
Also make sure to run `sudo chmod 600 /etc/mail/credentials` to make sure the password's aren't readable if you aren't running as sudo.
# 2. isync
Now we will setup isync to get our e-mail from our server's. In this example there is both settings for a selfhosted server and a gmail one.
# You don't need this, it just makes it easier to see date
Scan-Format: %c%u%r %-3n %10d %17f %t %2i%s
```
And now we are ready for using mblaze for managing our local mail with mblaze. Now for the rest of this blog I will show how I manage multiple account's using a scipt and a couple function's. I will also link a video that will show you in more detail things for using mblaze for managing your mail which was my inspiration for making this post.
# 4. Multiple profiles management
You can do this in a lot of ways with mblaze since it is very easily scriptable, but I do it with a script that copies over a preconfigure profile from `$HOME/.config/mblaze`
> example selfhost mblaze config `$HOME/.config/mblaze/selfhost`
The script is able to print the current profile when run without argument, listing all available profiles using -l and setting the profile by providing it's name.
For the rest of usage of mblaze, I really recommend to use `man mblaze` since the software is really well documented, or you can also watch this [video](https://piped.cronyakatsuki.xyz/watch?v=5YS8RPC4zwc) I took the inspiration from for this setup.
# Conclusion
Hope you have had a good read, and I hope you will maybe try out this mail setup, or create your own even better setup for your self.