Configure a Dedicated Server with Webmin
Part 12 - Email Accounts
01-Introduction - 02-Installing Webmin - 03-Configure DNS - 04-Assign Nameservers - 05-Configure SFTP - 06-Setup Web server - 07-Let's Encrypt - 08-Setup Perl/CGI PHP - 09-Manage MySQL - 10-Setup Email server - 11-Setup SASL - [[ 12-Setup Email accounts ]] - 13-Email process - 14-Email antivirus - 15-Usermin - 16-ExtrasConfigure Email boxes
Navigate at Servers > Postfix Mail Server.By clicking over "General Resource Control" icon you can modify how big your email inboxes are and some other important parameters for your email accounts.
Two important parameters to take note are:
Max size of a message: This option limits the size in bytes of a message that will be delivered, including the message envelope information.
Max size of a mailbox: The maximum size of an mailbox in bytes.
The default values are OK for start but you can modify them at your needs.

Setting up email users
Let's say we want to create two email accounts called: email@website1.com,email@website2.com
Go to System > Users and Groups and click the "Create a new user" link.
Give a Username ex : emailwebsite1
Home directory: Automatic
Shell: sbin/nologin
Password: Normal password. Give a password for this user.
Primary group: Existing group : postfix
Home directory: Automatic
Shell: sbin/nologin
Password: Normal password. Give a password for this user.
Primary group: Existing group : postfix

Click the "Create" button.
Do the same for the user emailwebsite2
Notice : Generally you do not need any aliases for the email@website1.com since website1.com is the main mail server.
So if you create the user "email" this will work out of the box for the email@website1.com.
If in "Postfix Mail Server" > "Mail Aliases" there is an "email" alias you can delete it.
Virtual domains can be used for local or non-local addresses, while aliases can only be used for local address.
Since the base email domain is website1.com, we have to use virtual domains and not aliases for the website2 domain and so on.
In our example we could have done :
Email: email@website1.com User: email -> No virtual domain is needed
Email: email@website2.com User: email2 -> Virtual domain is needed
But since the account "email" is not self explanatory i suggest doing something like this :
Email: email@website1.com User: emailwebsite1 -> Virtual domain is needed (we could also have used an alias).
Email: email@website2.com User: emailwebsite2 -> Virtual domain is needed.
Setting up Virtual Domains on Postfix
As we have seen in our example we need to make two virtual domains for our two email accounts. Go to Servers > Postfix Mail Server and click over "Virtual Domains" icon.Fill the "Virtual Domains" form like this :
Domain mapping lookup tables : Map specifications
Hit the [...] button and at the pop up window.
Select Mapping file /etc/postfix/virtual
Hit the "Save" button.
You should have : hash:/etc/postfix/virtual
Domains to perform virtual mapping for: website1.com, website2.com
Hit the [...] button and at the pop up window.
Select Mapping file /etc/postfix/virtual
Hit the "Save" button.
You should have : hash:/etc/postfix/virtual
Domains to perform virtual mapping for: website1.com, website2.com

Press "Save and apply" button.
Now again go at Servers > Postfix Mail Server and click over "Virtual Domains" icon.
Click the "Add a new mapping" link.
Fill the "Edit Map" form like this :
Description : email@website1.com
Name : email@website1.com
Maps to... : emailwebsite1 (user)
Name : email@website1.com
Maps to... : emailwebsite1 (user)

Click the "Save mapping" button.
Repeat for the second account email@website2.com
Click the "Add a new mapping" link.
Description : email@website2.com
Name : email@website2.com
Maps to... : emailwebsite2 (user)
Name : email@website2.com
Maps to... : emailwebsite2 (user)
Click the "Save mapping" button.
Finally stop and then start postfix
and stop and then start dovecot.
Our email system is set and is ready to use.
Sending and Receiving emails
Log into an external email account ex: freemail@yahoo.com Send an email at your newly created account email@website1.comYou can now check your mail box using Webmin.
Navigate to Servers > Read User Mail.
Click over the emailwebsite1 user.

You should have received a new email like the image below :

From the same interface you can also sent emails.
Since we have set up the IMAPS protocol now we are ready to configure an email client in order to receive and send our emails from email@website1.com. I will cover only Thunderbird as client the procedure is similar into any email client.
Run Thunderbird and click over File > New > Existing Mail Account.
Your name: Your name
Email address: email@website1.com
Password: password of the user emailwebsite1
Remember password : checked
Email address: email@website1.com
Password: password of the user emailwebsite1
Remember password : checked

Click the "Continue" button.
Fill the Mail Account Setup form like this :
Incoming: IMAP
Server hostname: mail.website1.com (use mail.website2.com for the email@website2.com)
Port: 993
SSL: SSL/TLS
Authentication method: Normal password
Username Incoming: emailwebsite1
Outgoing: SMTP
Server hostname: mail.website1.com
Port: 587
SSL: STARTTLS
Authentication method: Normal password
Username Outgoing: emailwebsite1
Port: 993
SSL: SSL/TLS
Authentication method: Normal password
Username Incoming: emailwebsite1
Outgoing: SMTP
Server hostname: mail.website1.com
Port: 587
SSL: STARTTLS
Authentication method: Normal password
Username Outgoing: emailwebsite1

Now you can receive and send emails using Thunderbird.
As we have alredy said, at the IMAP protocol, all the emails are stored in the server so we can access with different devices at our email account. The only downside is that if our server does not host any emails we will loose them from all of our devices.
In order to prevent this i suggest creating a folder "storage" into Thunderbird. (steps 1-3 at the image below.)
Now all the important Inboxed emails can be moved at the "storage" folder. (Steps a-d at the image below.)
Thunderbird will synchronize (and delete in case of server corruption) only the emails located at the Inbox folder.

In the next chapter we will discuss how we can process our received emails.
We are going to use SpamAssasun as spam filtering.
01-Introduction - 02-Installing Webmin - 03-Configure DNS - 04-Assign Nameservers - 05-Configure SFTP - 06-Setup Web server - 07-Let's Encrypt - 08-Setup Perl/CGI PHP - 09-Manage MySQL - 10-Setup Email server - 11-Setup SASL - [[ 12-Setup Email accounts ]] - 13-Email process - 14-Email antivirus - 15-Usermin - 16-Extras