# Self hosted email certificate renewal for docker mail server

**URL:** https://meta.discourse.org/t/self-hosted-email-certificate-renewal-for-docker-mail-server/357456
**Category:** Sysadmins
**Created:** [March 16, 2025, 4:27pm UTC](https://meta.discourse.org/t/self-hosted-email-certificate-renewal-for-docker-mail-server/357456 "2025-03-16T16:27:18Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Andrew\_Rowe](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andrew_rowe/32/445877_2.png) [@Andrew\_Rowe](https://meta.discourse.org/u/Andrew_Rowe)
#### Post date: [March 16, 2025, 4:27pm UTC](https://meta.discourse.org/t/self-hosted-email-certificate-renewal-for-docker-mail-server/357456/1 "2025-03-16T16:27:19Z")

</div>

This is a **How-To** for other self hosted administrators

I self host on a virtual private server (debian)

I use [docker-mailserver](https://github.com/docker-mailserver/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](https://docker-mailserver.github.io/docker-mailserver/latest/)

## 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

```plaintext
cd /var/discourse

```

stop Discourse

```plaintext
sudo ./launcher stop app

```

Step 2:  
Navigate to where certificates lives

```plaintext
cd /etc/letsencrypt

```

run certbot renew command

```plaintext
sudo certbot renew

```

you should see a message in the console such as

```plaintext
-----------------------------------------------------------
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

```plaintext
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

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [March 16, 2025, 5:17pm UTC](https://meta.discourse.org/t/self-hosted-email-certificate-renewal-for-docker-mail-server/357456/2 "2025-03-16T17:17:20Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Andrew\_Rowe](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andrew_rowe/32/445877_2.png) [@Andrew\_Rowe](https://meta.discourse.org/u/Andrew_Rowe)
#### Post date: [March 16, 2025, 5:29pm UTC](https://meta.discourse.org/t/self-hosted-email-certificate-renewal-for-docker-mail-server/357456/3 "2025-03-16T17:29:42Z")

</div>

I guess that would be too easy for me… 😅  
my mail server is [mail.mydomain.com](http://mail.mydomain.com)  
Discourse is [community.mydomain.com](http://community.mydomain.com)  
and regular web server is [mydomain.com](http://mydomain.com)

Thanks for the tip!
