[SOLVED] GitLab isn't sending emails via smtp to gmail

I have GItLab set up on a Linode running Arch. When I create a new user GitLab should be sending an email to that user, but emails are never received.

I configured smtp_settings.rb according to several guides online to use Gmail’s smtp server:

ActionMailer::Base.delivery_method = :smtp
  ActionMailer::Base.smtp_settings = {
    address: "smtp.gmail.com",
    port: 587,
    user_name: '********',
    password: '********',
    domain: 'gmail.com',
    authentication: :login,
    enable_starttls_auto: true,
    openssl_verify_mode: 'peer' # See ActionMailer documentation for other possible options
  }

(I’ve also tried :plain, ‘login’, and ‘plain’ for authentication)

According to the production log it appears the emails are being sent and I don’t see any errors:

Started POST "/admin/users" for 71.58.78.159 at 2017-09-07 18:07:07 +0000
Processing by Admin::UsersController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"[FILTERED]", "user"=>{"name"=>"********", "username"=>"********", "email"=>"********", "projects_limit"=>"100000", "can_create_group"=>"1", "access_level"=>"regular", "external"=>"0", "skype"=>"", "linkedin"=>"", "twitter"=>"", "website_url"=>""}}
[ActiveJob] Enqueued ActionMailer::DeliveryJob (Job ID: ed34d6a6-eb76-4d52-a10c-f6bca2a495cb) to Sidekiq(mailers) with arguments: "Notify", "new_user_email", "deliver_now", 11, "fmLG-k3X6X3abpu_Z1LV"
[ActiveJob] [ActionMailer::DeliveryJob] [ed34d6a6-eb76-4d52-a10c-f6bca2a495cb] Performing ActionMailer::DeliveryJob from Sidekiq(mailers) with arguments: "Notify", "new_user_email", "deliver_now", 11, "fmLG-k3X6X3abpu_Z1LV"
Scoped order and limit are ignored, it's forced to be batch order and batch size
Redirected to http://insightdv.com/admin/users/********
Completed 302 Found in 629ms (ActiveRecord: 57.6ms)
Started GET "/admin/users/********" for 71.58.78.159 at 2017-09-07 18:07:08 +0000
Processing by Admin::UsersController#show as HTML
  Parameters: {"id"=>"********"}
[ActiveJob] [ActionMailer::DeliveryJob] [ed34d6a6-eb76-4d52-a10c-f6bca2a495cb] 
Sent mail to ******** (92.9ms)
[ActiveJob] [ActionMailer::DeliveryJob] [ed34d6a6-eb76-4d52-a10c-f6bca2a495cb] Performed ActionMailer::DeliveryJob from Sidekiq(mailers) in 135.1ms
Completed 200 OK in 575ms (Views: 550.4ms | ActiveRecord: 12.7ms)
[ActiveJob] [ActionMailer::DeliveryJob] [ed34d6a6-eb76-4d52-a10c-f6bca2a495cb] Performing ActionMailer::DeliveryJob from Sidekiq(mailers) with arguments: "Notify", "new_user_email", "deliver_now", 11, "fmLG-k3X6X3abpu_Z1LV"
[ActiveJob] [ActionMailer::DeliveryJob] [ed34d6a6-eb76-4d52-a10c-f6bca2a495cb] 
Sent mail to ******** (108.9ms)
[ActiveJob] [ActionMailer::DeliveryJob] [ed34d6a6-eb76-4d52-a10c-f6bca2a495cb] Performed ActionMailer::DeliveryJob from Sidekiq(mailers) in 129.25ms
[ActiveJob] [ActionMailer::DeliveryJob] [ed34d6a6-eb76-4d52-a10c-f6bca2a495cb] Performing ActionMailer::DeliveryJob from Sidekiq(mailers) with arguments: "Notify", "new_user_email", "deliver_now", 11, "fmLG-k3X6X3abpu_Z1LV"
[ActiveJob] [ActionMailer::DeliveryJob] [ed34d6a6-eb76-4d52-a10c-f6bca2a495cb] 
Sent mail to ******** (89.6ms)
[ActiveJob] [ActionMailer::DeliveryJob] [ed34d6a6-eb76-4d52-a10c-f6bca2a495cb] Performed ActionMailer::DeliveryJob from Sidekiq(mailers) in 108.26ms

But the log keeps repeating DeliveryJob messages, so I’m guessing it just keeps retrying? Is there any way to get more information on what might be failing in the send?

Thanks!
Jayson

Got it working! I ran sidekiq manually (rather than via systemd) and saw a repeating set of ruby tracebacks complaining about a certificate error.

I changed the domain to ‘smtp.gmail.com’ and added

ca_file: '/etc/ssl/cert.pem'

to the end of smtp_settings.rb. I’m not sure if the domain change is necessary, but after adding the ca_file option it started working.