Self hosted email certificate renewal for docker mail server

This is a How-To for other self hosted administrators

I self host on a virtual private server (debian)

I use docker-mailserver to provide an email server for my Discourse instance. It is a really easy solution for simple transactional email server for Discourse. It saves the emails in files on the server and doesn’t need a database. It is a no-frills solution without an online interface or any other amenities, just postfix, dovecot, fail2ban and ClamAV.

Here are the Docs

Renew LetsEncrypt Certificates for docker-mailserver

I need to set up a cron job to renew my LetsEncrypt certificates but recently they expired so here is a quick step by step

Step 1:
you must stop Discourse so port 80 is available for certbot to run on
so navigate to the folder Discourse lives in

cd /var/discourse

stop Discourse

sudo ./launcher stop app

Step 2:
Navigate to where certificates lives

cd /etc/letsencrypt

run certbot renew command

sudo certbot renew

you should see a message in the console such as

-----------------------------------------------------------
Renewing an existing certificate for mail.mydomain.com
-----------------------------------------------------------
The following renewals succeeded:
   /etc/letsencrypt/live/mail.mydomain.com/fullchain.pem (success)

Step 3:
Navigate back to the folder where Discourse lives and start Discourse

cd /var/discourse
sudo ./launcher start app

Hope this helps someone
if you see any mistakes please feel free to post
If this topic is in the wrong location please feel free to move it
If this type of topic is not allowed please feel free to delete it

1 Like

If your mail server is the same domain name as your email server, you should be able to use the certs that Discourse maintains

I guess that would be too easy for me… :sweat_smile:
my mail server is mail.mydomain.com
Discourse is community.mydomain.com
and regular web server is mydomain.com

Thanks for the tip!

1 Like