Reputation: 9179
My Gitlab (version 5) is not sending any e-mails and I am lost trying to figure out what is happening. The logs give no useful information. I configured it to used sendmail
.
I wrote a small script that sends e-mail through ActionMailer (I guess it is what gitlab uses to send e-mail, right?). And it sends the e-mail correctly.
But, on my Gitlab, I can guarantee that sendmail is not even being called.
Do I need to enable something to get e-mail notifications? How can I debug my issue?
The problem is that I can not find any information anywhere. The thing just fails silently. Where can I find some kind of log? The logs in the log
dir provide no useful information.
My question is, how can I make Gitlab be more verbose? How can I make it tell me what is going on?
I just found a lot of mails scheduled on the Background jobs
section. A lot of unprocessed Sidekiq::Extensions::DelayedMailer
. What does it mean? Why were these jobs not processed?
Upvotes: 39
Views: 57379
Reputation: 6273
I had the same problem and while I don't recommend tinkering with the GitLab source code, I was able to do my debugging with a mod to application.rb
:
diff --git a/config/application.rb b/config/application.rb
index d85bcab..274976f 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -11,6 +11,8 @@ end
module Gitlab
class Application < Rails::Application
+ config.action_mailer.sendmail_settings = { :arguments => "-i" }
+
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
Note: I'm running Debian 7 which uses exim for mail.
Update Oct 2023: I don't expect this to be done to a production environment, and this was done 9 years ago ... before GitLab had the options available that it does today. Please review the GitLab documentation, your mileage may vary.
Upvotes: 0
Reputation: 2318
Stumbled upon this issue today, here's my research:
Debugging SMTP connections in the GitLab GUI is not supported yet. However there is a pending feature request and a command line solution.
Set the desired SMTP settings /etc/gitlab/gitlab.rb
and run gitlab-ctl reconfigure
(see https://docs.gitlab.com/omnibus/settings/smtp.html).
Start the console running gitlab-rails console -e production
.
Show the configured delivery method (should be :smtp
) running the command ActionMailer::Base.delivery_method
. Show all configured SMTP settings running ActionMailer::Base.smtp_settings
.
To send a test mail run
Notify.test_email('[email protected]', 'Hello World', 'This is a test message').deliver_now
On the admin page in GitLab, the section »Background jobs« shows information about all jobs. Failing SMTP connections are listed there as well.
Please note, you may need to restart the GitLab instance in order to use the newly configured SMTP settings (on my instance the console was able to send mails, the GUI required a restart). Run gitlab-ctl restart
to restart your instance.
Upvotes: 53
Reputation: 3181
In the admin section under Background Jobs if you have lots of items in the Scheduled tab try restarting sidekiq
:
cd /home/git/gitlab
exec rake sidekiq:start RAILS_ENV=production
Upvotes: 1
Reputation: 9179
First, I will tell what was my problem: The sidekiq is responsible for handling sending e-mails. For some reason my sidekiq was stuck, restarting it solved the problem.
Where I found information about problems I found on Gitlab:
And if you reach this point, you may modify Gitlab's code so you can "trace it" writing to a file:
File.open('/tmp/logfile','a') { |file| file.write("Hello World!\n") }
Upvotes: 9
Reputation: 20858
Maybe try enabling delivery errors in production mode and see what happens
config.action_mailer.raise_delivery_errors = true
Upvotes: 3