Send email with Gitlab docker image

12,006

The instructions you followed are for a different docker image than the one you're actually using. You also set up IMAP, which is for receiving emails. In GitLab's case, it's for replying to issues by email.

What you want are the SMTP settings. The GitLab docker image does not come with sendmail installed, so you will have to follow the instructions here to set up SMTP in GitLab: https://docs.gitlab.com/omnibus/settings/smtp.html#example-configuration

You can dump gitlab.rb configuration right in your docker-compose under the environment section. My Fastmail setup for reference:

environment:
    GITLAB_OMNIBUS_CONFIG: |
        gitlab_rails['smtp_enable'] = true 
        gitlab_rails['smtp_address'] = "***"
        gitlab_rails['smtp_port'] = 465    
        gitlab_rails['smtp_user_name'] = "***"
        gitlab_rails['smtp_password'] = "***"
        gitlab_rails['smtp_enable_starttls_auto'] = true
        gitlab_rails['smtp_tls'] = true    
        gitlab_rails['smtp_openssl_verify_mode'] = 'peer'
Share:
12,006
Hurobaki
Author by

Hurobaki

I am a computer student and I try to help people in the Stack community as they helped me during times when I had problems on my code ;)

Updated on June 12, 2022

Comments

  • Hurobaki
    Hurobaki almost 2 years

    Here's my goal, I would like to configure emails for my Gitlab server. I followed a lot of tutorials but I can't make it work.

    My configuration is the following, I've got a reverse-proxy in a Docker container and my Gitlab server also in a Docker container.

    About versions :

    Docker version 17.09.0-ce, build afdb6d4
    docker-compose version 1.16.1, build 6d1ac21
    

    Here's my docker-compose.yml file

    version: '3.3'
    
    networks:
       proxy: 
         external: true
       internal:
         external: false
    
    services:
      gitlab:
        image: gitlab/gitlab-ce:latest
        container_name: gitlab
        environment:
            - TZ=Europe/Paris
            - GITLAB_TIMEZONE=Paris
            - [email protected]
            - IMAP_PASSWORD=MYGMAILPASS
            - GITLAB_INCOMING_EMAIL_ADDRESS=USERGMAIL+%{key}@gmail.com
        volumes:
            - /srv/gitlab/config:/etc/gitlab
            - /srv/gitlab/logs:/var/log/gitlab
            - /srv/gitlab/data:/var/opt/gitlab
        restart: always
        labels:
            - traefik.backend=gitlab
            - traefik.frontend.rule=Host:git.domain.com
            - traefik.docker.network=proxy
            - traefik.port=80
            - traefik.frontend.entryPoints=http,https
        networks:
            - internal
            - proxy
    

    I followed this tutorial which seems to be good :

    https://github.com/sameersbn/docker-gitlab#available-configuration-parameters

    I must miss something in my configuration but I can't figure out what is it ...

    Does anyone can help me to configure email sending ? I don't know either the proper way to test email sending from GitLab.

    Is the best way is to configure from docker-compose environment variables or directly from gitlab.rb file ?

    Some help would be much appreciated