Coffee Mailserver Support - https://blog.lowlevelforest.com/
This repository provides a Bash script for setting up and managing a mail server using Postfix and Dovecot. It includes features for creating and managing users, domains, and emails.
- A VPS or dedicated server running Ubuntu.
- Root access to the server.
- Basic knowledge of Linux command line.
-
Clone the repository to your server:
git clone https://github.com/coffeecms/coffee_mailserver_support.git cd coffee_mailserver_support -
Make the script executable:
chmod +x mailserver_setup.sh
-
Run the script:
sudo ./mailserver_setup.sh
After running the script, you'll see a menu with the following options:
- Install Postfix & Dovecot: Installs and configures the mail server.
- Optimize Postfix & Dovecot: Adjusts settings based on server specifications.
- List Domains: Displays the currently configured domains.
- Add Domain: Adds a new domain to the mail server.
- Remove Domain: Removes an existing domain from the mail server.
- Add User: Creates a new email user.
- Create Random Users: Generates random email users.
- Read Email of User: Allows users to read their emails.
- Delete All Emails of a User: Removes all emails for a specified user.
- Delete All Emails: Permanently deletes all emails from the server.
- Delete Emails Older Than n Days: Deletes emails older than a specified number of days.
- Delete Users from File: Removes users listed in a specified file.
- Create Users from File: Creates users with passwords from a specified file.
- Exit: Closes the script.
-
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: ********
To ensure your mail server operates correctly, you need to configure DNS records for your domain. Follow these steps:
-
A Record: Point your domain to your server's IP address.
Type: A Host: @ Value: <your-server-ip> TTL: 3600 -
MX Record: Set the mail exchange record for your domain.
Type: MX Host: @ Value: mail.example.com Priority: 10 TTL: 3600 -
SPF Record: Add an SPF record to authorize your server to send emails.
Type: TXT Host: @ Value: "v=spf1 a mx ip4:<your-server-ip> -all" TTL: 3600 -
DKIM Record: If you have DKIM enabled, add the DKIM public key as a TXT record.
Type: TXT Host: default._domainkey Value: "v=DKIM1; k=rsa; p=<your-dkim-public-key>" TTL: 3600 -
DMARC Record: Optionally, set up DMARC to control email authentication.
Type: TXT Host: _dmarc Value: "v=DMARC1; p=none; rua=mailto:postmaster@example.com" TTL: 3600
After installation, you can add your domain by selecting the option in the menu and entering your domain name.
Select the domain you want to create a user for and provide a username. The script will generate a random password for you.
To delete emails for a user, select the appropriate option, enter the username, and confirm the action.
This project is licensed under the MIT License - see the LICENSE file for details.
- Replace
<your-server-ip>and<your-dkim-public-key>with the actual values for your mail server. - Ensure that the instructions match the actual behavior of your script, and feel free to customize any sections as needed.