Configure GitLab to send email over SMTP
Self-managed GitLab (Linux package) sends notifications, password resets and confirmations with the `gitlab_rails['smtp_*']` keys in `/etc/gitlab/gitlab.rb`. The common mistake is turning on both TLS flags: `smtp_enable_starttls_auto` is for 587, `smtp_tls` is for 465, and setting both to `true` fails with `:enable_starttls and :tls are mutually exclusive`.
Create a send-only key
In Unitpost, open Settings → SMTP and create a send-only key. GitLab sends as
gitlab_email_from, so pick that address on a verified domain.Add the SMTP block to gitlab.rb
Edit
/etc/gitlab/gitlab.rbon the GitLab server. For port 587, keepsmtp_enable_starttls_autoon andsmtp_tlsoff.Rubygitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.unitpost.com" gitlab_rails['smtp_port'] = 587 gitlab_rails['smtp_user_name'] = "unitpost" gitlab_rails['smtp_password'] = "pk_live_..." gitlab_rails['smtp_domain'] = "yourdomain.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = false gitlab_rails['smtp_openssl_verify_mode'] = 'peer' gitlab_rails['gitlab_email_from'] = 'gitlab@yourdomain.com' gitlab_rails['gitlab_email_reply_to'] = 'noreply@yourdomain.com'For port 465, set
smtp_portto465,smtp_tlstotrueandsmtp_enable_starttls_autotofalse.Reconfigure GitLab
Changes in
gitlab.rbapply only after a reconfigure.Shellsudo gitlab-ctl reconfigureSend a test from the Rails console
Open the console with
sudo gitlab-rails console, then send a message withNotify.test_email. A failure prints the SMTP error right there; a success shows up in Unitpost Emails.RubyNotify.test_email('you@example.com', 'Unitpost SMTP test', 'Sent from GitLab').deliver_nowIf it fails
In the same console,
ActionMailer::Base.smtp_settingsshows what GitLab loaded.535 5.7.8meanssmtp_user_nameisn'tunitpost.550 5.7.1meansgitlab_email_fromisn't on a verified domain. Themutually exclusiveerror means both TLS flags aretrue.