Gitea via Docker: Using sendmail for notifications


I’m running Gitea in a Docker container (setup details below). I’mm attempting to enable email notifications using Sendmail, but I fail. Gitea gives an error message when I try to send a test mail (details below). Using sendmail in the container also fails:

{host}$ docker-compose exec server /bin/bash
WARNING: The GITEA_USER_UID variable is not set. Defaulting to a blank string.
WARNING: The GITEA_USER_GID variable is not set. Defaulting to a blank string.
bash-4.3# echo "Subject: Test" | sendmail -v
sendmail: can't connect to remote host ( Connection refused

I’ve verified that sendmail works on the host and that the message is delievered, e.g.

{host}$ echo "Subject: Test" | sendmail -v
Mail Delivery Status Report will be mailed to <alice>.


I’m a rookie with both Gitea and Docker.

  • Can I expect Sendmail to work with the Gitea 1.3.2 Docker container?

  • Is there anything I need to configure in my docker-compose.yml file (details below)?

  • Do I need to tweak the Dockerfile, e.g. install additional software?

My Gitea Setup

I’m running Gitea in a Docker container configured as:

$ cat docker-compose.yml 
version: "2"

    external: false

    image: gitea/gitea:1.3.2
    restart: always
      - gitea
      - ./gitea:/data:Z
      - "8080:3000"
      - "2022:22"

In gitea/conf/app.ini, I have:

ENABLED = true
SENDMAIL_PATH = /usr/sbin/sendmail

After restarting, The ‘Mailer Configuration’ panel under ‘Configuration’ shows:

Enabled                    : [x]
Name                       : Gitea Hub
Use                        : Sendmail
Sendmail Path              : /usr/sbin/sendmail
Extra arguments to Sendmail: []
User:                      : (empty)

When I enter am email address and hit ‘Send Test Mail’, the ‘Configuration’ page responds with error: “Failed to send test email to ‘’: gomail: could not send email 1: exit status 1”.


I’ve solved this. There were two things that needed to be solved.

  1. Previously I was running the Docker daemon with iptables: false set in /etc/docker/daemon.json (corresponding to Dockers’ command-line option --iptables=true). This prevented sendmail from Docker to access external hosts. It was not even possible ping outside the host.

  2. I’ve got access to an external SMTP server which have sendmail use by setting SENDMAIL_ARGS = -S in gitea/conf/app.ini. (Using HOST = was ignored, so had to use SENDMAIL_ARGS).

The following is what I now have in gitea/conf/app.ini and what works:

ENABLED = true
SENDMAIL_PATH = /usr/sbin/sendmail

I’m running the Docker Gitea 1.3.2 image.


However, when I use Sendmail, which is BusyBox’s Sendmail when run from the Docker container, I have the following issues:

  1. On the receiving end, the text/html content is rendered as text/plain, so very “cluttered” messages go out this way. I don’t know if this is an issue with BusyBox Sendmail, or the SMTP server. When using sendmail -v, the output looks fine to me.

  2. When sending to a account, Google/Gmail refuses to receive the message because it’s “non-RFC 5322 compliant” due to “‘From’ header is missing.”. I also don’t know why this is because, again, the sendmail -v output looks fine and there is indeed a From: line sent in addition to a MAIL FROM: line.

Final-Recipient: rfc822;
Action: failed
Status: 5.5.0
Diagnostic-Code: smtp;550-5.7.1 [      11] Our system has detected that this message is
550-5.7.1 not RFC 5322 compliant:
550-5.7.1 'From' header is missing.
550-5.7.1 To reduce the amount of spam sent to Gmail, this message has been
550-5.7.1 blocked. Please visit
550 5.7.1 and review RFC 5322 specifications for more information. a23si1019813pff.83 - gsmtp

Updating my gitea/conf/app.ini to not use Sendmail, but go directly to the SMTP server, solves both problems: HTML messages are going out as proper text/html and Gmail is happy and delivers it. To conclude, the following seems to work from within Gitea Docker:

ENABLED = true