Gitlab SMTP Settings won't reconfigure

So I’ve been using Gitlab for years, and never been able to get the SMTP settings to work; it’s only been me for the longest time, so there wasn’t a need to send emails out.
I’ve recently updated it from 12.9 to the latest version.

I am running Gitlab on a server from home, literally within arm’s reach from where I type.
I’ve ran through the documentation, adding the SMTP details in gitlab.rb and ran gitlab-ctl reconfigure.

Now, it seems like it has updated once, since when I check ActionMailer, it does return with some values which I once placed, however, I’ve tried changing these and even commenting them out, and they will not change.

I have reconfigured, restarted, and even rebooted the machine, and nothing changes.
The strange thing is, that the username is the default gitlab@[server] (not what I entered) and the password is something which I do not recognise at all.

Any ideas?

Without seeing the settings you completed in gitlab.rb, will be difficult to see where the problem is. This is how mine looks, because I don’t use the config in gitlab.rb, but I do it a different way:

### GitLab email server settings
###! Docs: https://docs.gitlab.com/omnibus/settings/smtp.html
###! **Use smtp instead of sendmail/postfix.**

# gitlab_rails['smtp_enable'] = true
# gitlab_rails['smtp_address'] = "smtp.server"
# gitlab_rails['smtp_port'] = 465
# gitlab_rails['smtp_user_name'] = "smtp user"
# gitlab_rails['smtp_password'] = "smtp password"
# gitlab_rails['smtp_domain'] = "example.com"
# gitlab_rails['smtp_authentication'] = "login"
# gitlab_rails['smtp_enable_starttls_auto'] = true
# gitlab_rails['smtp_tls'] = false

but anyway, you would need to ensure the above items (not necessarily all of them, just some), are configured correctly, and that username/password are actually surrounded by quotes (as above in the commented example config).

As I said, I don’t use this, because I have postfix configured on my Linux server, so it utilises this without me having to configure gitlab to access a particular SMTP server. Of course, you can do that if you are OK with configuring postfix and getting it to relay your emails to your mail server. This way has other issues, eg: IP address of your server sending the emails not being authorised to send for your email domain if it’s using SPF records etc, or servers making revDNS/ptr lookups for an IP that has an invalid PTR for mail delivery. But providing that these have been addressed during initial configuration in your DNS records, etc, then later it’s not an issue.

Re-check your settings in gitlab.rb based on the above example config. If it’s not working, then post your config here so we can see what you’ve done - without posting sensitive information like username/passwords.

Thanks for the info.

My gitlab.rb essentially looks like that, except I’ve without it being commented.
Honestly, I’ve tried changing it several times. First using Google Workspace, then Gmail, tried localhost. Even removing the lines completely doesn’t update it (it still uses smtp.gmail.com for instance).

And I don’t even recognise the password in the Rails console, which makes me think there is another settings being applied somewhere.

I’d post my config… except I don’t know an easy way how (I use nano and copy/pasting with that is very hit and miss I’ve found). Could you suggest a better method?

So if I use postfix (I cannot remember if I installed it on this server), will there be any issues in sending “internal” emails even if they’re on different servers? I’ve got a cron job to update the gitlab server’s IP on DNS records each morning.

Localhost would only work if you have an SMTP daemon installed like postfix, sendmail etc. You could also configure postfix/sendmail to relay messages from your gitlab server directly to your mail server. (by default it will attempt to send via the internet to your mailserver which has more chance of being rejected).

With postfix, you can do it like this:

relayhost = mymailserver.domain.com

if the gitlab server is resolving DNS correctly it will find it. Be it using the internal IP of the server, or the external public one.

That alone should help get you working, as you will then see in /var/log/mail.log (Debian/Ubuntu) or /var/log/maillog (RHEL/CENTOS) if it is sending to your mail server. If they get rejected, then you would need to find out why the server isn’t accepting what you are trying to send, and debug it from there. For example, if your mail server won’t accept relayed email without authentication. For internal IP subnets, you can configure safely allow relay without authentication, but if via public IP, make sure authentication is used, else you will become an open relay from your mailserver for sending spam. So be careful with that.

Update: managed to get it sorted. There were duplicate settings in the config. These were removed and now it sends emails (yet to actually receive one) :smiley:

1 Like