Skip to content

Instantly share code, notes, and snippets.

@opentaq
Last active April 6, 2024 23:56
Show Gist options
  • Star 21 You must be signed in to star a gist
  • Fork 12 You must be signed in to fork a gist
  • Save opentaq/2ce85108bee528700477c6db89610968 to your computer and use it in GitHub Desktop.
Save opentaq/2ce85108bee528700477c6db89610968 to your computer and use it in GitHub Desktop.
Mailserver Installation

Fail2Ban

sudo install fail2ban

UFW

sudo install ufw

UFW Settings

sudu ufw default deny incomoing

sudo ufw default allow outgoins

sudo ufw allow 22,25,80,110,143,443,465,587,993,995,4190/tcp

sudo ufw enable

Mailserver

Install curl and git

sudo apt install curl git -y

Install Docker

su

curl -sSL https://get.docker.com/ | CHANNEL=stable sh

systemctl enable --now docker

Install Docker Compose

curl -sSL https://github.com/docker/compose/releases/download/v$(curl -Ls https://www.servercow.de/docker-compose/latest)/docker-compose-$(uname -s)-$(uname -m) > /usr/local/bin/docker-compose

chmod +x /usr/local/bin/docker-compose

Install the mail server

su

cd /opt

git clone https://github.com/mailcow/mailcow-dockerized

cd mailcow-dockerized

./generate_config.sh

Start the mail server

docker-compose pull

docker-compose up -d

@balavec
Copy link

balavec commented Jul 29, 2022

Hey my friend, you might want to update the docker compose install script to:
curl -sSL https://github.com/docker/compose/releases/download/v$(curl -Ls https://www.servercow.de/docker-compose/latest)/docker-compose-$(uname -s)-$(uname -m) > /usr/local/bin/docker-compose

@balavec
Copy link

balavec commented Jul 29, 2022

And also the:
./generate_config.sh

@opentaq
Copy link
Author

opentaq commented Aug 12, 2022

Hey my friend, you might want to update the docker compose install script to: curl -sSL https://github.com/docker/compose/releases/download/v$(curl -Ls https://www.servercow.de/docker-compose/latest)/docker-compose-$(uname -s)-$(uname -m) > /usr/local/bin/docker-compose

Happily done. :-)

@opentaq
Copy link
Author

opentaq commented Aug 12, 2022

And also the: ./generate_config.sh

You're right!

@mhadjih2
Copy link

mhadjih2 commented Sep 4, 2022

Hello, and thanks for your contribution and great video. There are still a few things to adjust I think though:

sudo install fail2ban -->> sudo apt-get install fail2ban
sudo install ufw -->> sudo apt-get install ufw
sudu ufw default deny incomoing -->> sudu ufw default deny incoming
sudo ufw default allow outgoins -->> sudo ufw default allow outgoing

@WooZyDice
Copy link

There are still a few things to adjust I think though

Yeah, this gist should be updated to reflect those corrections. For the package installations, use apt instead of apt-get since the commands were not intended to be used by a script.

@iAjEPIC
Copy link

iAjEPIC commented Nov 4, 2022

hello friends,
i have an issue in Mailcow,
i am sending bluk email at once, but i do not know which type of email list i can paste in BCC,
i tried comma (,) dot (.) etc.
i have total email list in excel sheet
please help me how i can send bulk email at once from Mailcow Sogo inbox

Regard

@git529
Copy link

git529 commented Dec 1, 2022

Great tutorial, thanks. Why do you install fail2ban when the mailcow installation already provides a fail2ban instance?

@priyank2006
Copy link

priyank2006 commented Jun 5, 2023

Hey Guys,

Which Static IP SHould I use for better deliveries to gmail ?

means which ISP's IP should I use ??

Thanks In Advance

@PietroFantini
Copy link

@priyank2006
Hello I suggest you hetzner in my case the ip of the vps they gave me had problem with outlook but they supported me to get the ips withlisted, care you will not beable to send emails cause their vps ports are limited for outgoing emails until the first bill (1month) I'm still a ovh client, hetzner is cheaper and the support is waayy better even the managment of the vps is sooo much better, I'm looking to migrate there with all my vps ! (maybe try to ask them if they can unlock your ports before the month if you really need it)
Good luck :) !

@elrobococo
Copy link

Thank you so much!

@priyank2006
Copy link

@priyank2006 Hello I suggest you hetzner in my case the ip of the vps they gave me had problem with outlook but they supported me to get the ips withlisted, care you will not beable to send emails cause their vps ports are limited for outgoing emails until the first bill (1month) I'm still a ovh client, hetzner is cheaper and the support is waayy better even the managment of the vps is sooo much better, I'm looking to migrate there with all my vps ! (maybe try to ask them if they can unlock your ports before the month if you really need it) Good luck :) !

But dear, I Dont want VPS. Only ISP who provides me limitation free Dedicated IP Pool for making SMTP Server.
Thanks for your reply

@LiamPerson
Copy link

I recommend instead using this install script for docker as it makes it far easier to manage the versions, removing, and updating:
https://docs.docker.com/engine/install/debian/#install-using-the-repository

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

@nicitaacom
Copy link

nicitaacom commented Mar 18, 2024

> sudo install fail2ban -->> sudo apt-get install fail2ban
> sudo install ufw -->> sudo apt-get install ufw
> sudu ufw default deny incomoing -->> sudu ufw default deny incoming
> sudo ufw default allow outgoins -->> sudo ufw default allow outgoing

It throw error

root@box:/opt/mailcow-dockerized# sudo install fail2ban -->> sudo apt-get install fail2ban
sudo install ufw -->> sudo apt-get install ufw
sudu ufw default deny incomoing -->> sudu ufw default deny incoming
sudo ufw default allow outgoins -->> sudo ufw default allow outgoing
install: target 'fail2ban' is not a directory
install: target 'ufw' is not a directory
Command 'sudu' not found, did you mean:
  command 'tudu' from deb tudu (0.10.4-1)
  command 'sudo' from deb sudo (1.9.9-1ubuntu2.4)
  command 'sudo' from deb sudo-ldap (1.9.9-1ubuntu2.4)
Try: apt install <deb name>
ERROR: Invalid syntax
root@box:/opt/mailcow-d

I think you need
sudo apt-get install fail2ban
sudo apt-get install ufw
sudo ufw default deny incoming
sudo ufw default allow outgoing

Also somebody know how to fix this error?

ubuntu@ip-172-26-0-78:~$ systemctl enable --now docker
Synchronizing state of docker.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable docker
==== AUTHENTICATING FOR org.freedesktop.systemd1.reload-daemon ===
Authentication is required to reload the systemd state.
Authenticating as: Ubuntu (ubuntu)
Password:
polkit-agent-helper-1: pam_authenticate failed: Authentication failure
==== AUTHENTICATION FAILED ===
Failed to reload daemon: Access denied

I use AWS and I don't know my password

@isanecat
Copy link

how to get ssl certificate ?

@nicitaacom
Copy link

how to get ssl certificate ?

https://certbot.eff.org/

@PietroFantini
Copy link

how to get ssl certificate ?

Don't panic is automatic, sometimes it just takes a little more time ^^

@Chi3ftain
Copy link

Hey Guys,

Which Static IP SHould I use for better deliveries to gmail ?

means which ISP's IP should I use ??

Thanks In Advance

your ISP's maybe?

@isanecat
Copy link

isanecat commented Apr 3, 2024

contabo or vultr are good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment