How to setup Gitlab with SMTP, DNS and CentOS?

Hi Community,

I’m a huge fan of GitLab and thats why I want to host my own instance in a docker container. Sadly I’m not able to setup the smtp configuration properly. It is the first own linux server I own > root cause found :wink:

So because I don’t know exactly where to start, I’ll just write down everything which maybe is important.

I do have an MX record setup pointing to:

I did follow this guide:

I set:

myhostname =
inet_interfaces = all
inet_protocols = all
mydestination =,, localhost.localdomain, localhost
home_mailbox = Maildir/

Now I’m able to send me and E-Mail via Telnet locally and receive it via mail. I’m not able to send me an E-Mail to my Gmail account with this telnet command. --> First problem

Second problem: I got a HTTP 500, if I want to e.g. verify my email address of a user in GitLab.

Sent mail to (31.6ms)
Completed 500 Internal Server Error in 1094ms (ActiveRecord: 6.4ms)
Errno::ENETUNREACH (Network is unreachable - connect(2) for “localhost” port 25):

I changed the following parts in the gitlab.rb, went into the container and ran a reconfigure.

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = ""
gitlab_rails['smtp_port'] = 25
# gitlab_rails['smtp_user_name'] = "smtp user"
# gitlab_rails['smtp_password'] = "smtp password"
gitlab_rails['smtp_domain'] ="
# gitlab_rails['smtp_authentication'] = "login"
# gitlab_rails['smtp_enable_starttls_auto'] = true
# gitlab_rails['smtp_tls'] = false

I’m a little bit confused at the moment.
I guess I should look at postfix first, because I can’t send mails outside of my server atm.

Second would be to take a look at the gitlab config and the HTTP 500 with the connection problem due to port 25. I’m wondering here, because there is not a single documentation that you have to open that port while starting the container, or am I blind?

Please check my configurations and tell me if something is wrong there.

Best regards from Berlin,


iptables -I INPUT -p tcp -m tcp --dport 25 -j ACCEPT
sudo firewall-cmd --permanent --add-service=smtp