This guide will walk you through setting up and managing a mail server using Coffee Mailserver Support. Leveraging Postfix and Dovecot, this repository provides a Bash script for easy management of users, domains, and emails.
Prerequisites
Before you begin, ensure you have the following:
- A VPS or dedicated server running Ubuntu.
- Root access to the server.
- Basic knowledge of the Linux command line.
Installation
- Clone the Repository Open your terminal and run:
git clone https://github.com/coffeecms/coffee_mailserver_support.git
cd coffee_mailserver_support
- Make the Script Executable Run the following command:
chmod +x mailserver_setup.sh
- Run the Script Execute the script with root privileges:
sudo ./mailserver_setup.sh
Usage
Main Menu Options
Upon running the script, a menu will appear with the following options:
- Install Postfix & Dovecot
- Optimize Postfix & Dovecot
- List Domains
- Add Domain
- Remove Domain
- Add User
- Create Random Users
- Read Email of User
- Delete All Emails of a User
- Delete All Emails
- Delete Emails Older Than n Days
- Delete Users from File
- Create Users from File
- Exit
Example Commands
- To Add a Domain: Enter the domain name:
example.com
- To Create a User: Select a domain:
example.com
Enter the username:user1
- To Read Emails for a User: Enter user (e.g.,
user@example.com
):user1@example.com
Enter password:********
DNS Configuration
Proper DNS configuration is crucial for the mail server’s functionality. Follow these steps:
- A Record: Point your domain to your server’s IP address. Type Host Value TTL A @
<your-server-ip>
3600 - MX Record: Set the mail exchange record for your domain. Type Host Value Priority TTL MX @
mail.example.com
10 3600 - SPF Record: Authorize your server to send emails. Type Host Value TTL TXT @
"v=spf1 a mx ip4:<your-server-ip> -all"
3600 - DKIM Record: If DKIM is enabled, add the public key. Type Host Value TTL TXT
default._domainkey
"v=DKIM1; k=rsa; p=<your-dkim-public-key>"
3600 - DMARC Record: Optionally set up DMARC for email authentication. Type Host Value TTL TXT
_dmarc
"v=DMARC1; p=none; rua=mailto:postmaster@example.com"
3600
Examples
- Adding a Domain: After installation, add your domain by selecting the option in the menu and entering your domain name.
- Creating a User: Select the domain and provide a username. The script will generate a random password for you.
- Deleting Emails: To delete emails for a user, select the option, enter the username, and confirm the action.
License
This project is licensed under the MIT License. For more details, see the LICENSE file in the repository.
Notes
- Replace
<your-server-ip>
and<your-dkim-public-key>
with your actual values. - Ensure the instructions match the behavior of your script, and feel free to customize any sections as needed.
Leave a Reply