14

I just recently install GitLab v5.0 on an Ubuntu 12.04 server and am now having issues with email notifications. I can't get GitLab to send any emails of any kind.

I've got my config/environments/production.rb file setup to use sendmail as the transport service:

config.action_mailer.delivery_method = :sendmail
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true

And I can manually use sendmail successfully from the shell as described here: http://scratching.psybermonkey.net/2011/03/sendmail-how-to-test-sending-email.html

My config/gitlab.yml file is setup with the following email setting:

email_from: gitlab@myops.com

I've read that it could be a problem with Sidekiq not running so I ran the following command but nothing has changed.. I still can't send emails:

$ sudo -u git -H bundle exec rake sidekiq:start RAILS_ENV=production
$ ps aux |grep -i sidekiq
git       2791  2.1  4.2 206476 86620 pts/0    Sl   14:45   0:23 sidekiq 2.7.5 gitlab [0 of 25 busy] 

Which indicates to me that Sidekiq is indeed running... what else could be the issue here? There doesn't seem to be much documentation on GitLab's wiki regarding email settings unfortunately...

I found the following error being logged in sidekiq.log:

2013-04-24T21:09:01Z 2791 TID-1jaur8 Sidekiq::Extensions::DelayedMailer JID-21bd3ec0f086351088992396 INFO: start
2013-04-24T21:09:01Z 2791 TID-1jaur8 Sidekiq::Extensions::DelayedMailer JID-21bd3ec0f086351088992396 INFO: fail: 0.004 sec
2013-04-24T21:09:01Z 2791 TID-1jaur8 WARN: {"retry"=>true, "queue"=>"default", "timeout"=>30, "class"=>"Sidekiq::Extensions::DelayedMailer", "args"=>["---\n- !ruby/class 'Notify'\n- :new_user_email\n- - 4\n - pSzzULp8\n"], "at"=>1366819034.5969028, "jid"=>"21bd3ec0f086351088992396", "error_message"=>"Couldn't find User with id=4", "error_class"=>"ActiveRecord::RecordNotFound", "failed_at"=>"2013-04-24T15:57:19Z", "retry_count"=>10, "retried_at"=>2013-04-24 21:09:01 UTC}
2013-04-24T21:09:01Z 2791 TID-1jaur8 WARN: Couldn't find User with id=4
2013-04-24T21:09:01Z 2791 TID-1jaur8 WARN: /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/relation/finder_methods.rb:343:in `find_one'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/relation/finder_methods.rb:314:in `find_with_ids'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/relation/finder_methods.rb:107:in `find'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/querying.rb:5:in `find'
/home/git/gitlab/app/mailers/notify.rb:23:in `new_user_email'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/base.rb:167:in `process_action'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/base.rb:121:in `process'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/rendering.rb:45:in `process'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.13/lib/action_mailer/base.rb:459:in `process'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.13/lib/action_mailer/base.rb:453:in `initialize'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.13/lib/action_mailer/base.rb:439:in `new'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.13/lib/action_mailer/base.rb:439:in `method_missing'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/extensions/action_mailer.rb:20:in `perform'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/processor.rb:45:in `block (3 levels) in process'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/chain.rb:109:in `call'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/chain.rb:109:in `block in invoke'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/server/timeout.rb:11:in `block in call'
/usr/local/lib/ruby/1.9.1/timeout.rb:68:in `timeout'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/server/timeout.rb:10:in `call'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/chain.rb:111:in `block in invoke'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/server/active_record.rb:6:in `call'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/chain.rb:111:in `block in invoke'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/server/retry_jobs.rb:49:in `call'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/chain.rb:111:in `block in invoke'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/server/logging.rb:11:in `block in call'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/logging.rb:22:in `with_context'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/server/logging.rb:7:in `call'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/chain.rb:111:in `block in invoke'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/chain.rb:114:in `call'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/chain.rb:114:in `invoke'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/processor.rb:44:in `block (2 levels) in process'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/processor.rb:80:in `stats'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/processor.rb:43:in `block in process'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/celluloid-0.12.4/lib/celluloid/calls.rb:23:in `call'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/celluloid-0.12.4/lib/celluloid/calls.rb:23:in `public_send'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/celluloid-0.12.4/lib/celluloid/calls.rb:23:in `dispatch'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/celluloid-0.12.4/lib/celluloid/future.rb:18:in `block in initialize'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/celluloid-0.12.4/lib/celluloid/internal_pool.rb:48:in `call'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/celluloid-0.12.4/lib/celluloid/internal_pool.rb:48:in `block in create'

Any ideas?

sadmicrowave
  • 39,964
  • 34
  • 108
  • 180
  • I'm not sure this is the correct medium for Gitlab questions since it isn't directly related to programming. But for what it's worth, I'd check `/admin/logs` through a web browser and see if you're getting any random errors with SideKiq or something saying jobs are failing. Also look through the `log` directory in the root of the gitlab application on the server. – Steven V Apr 24 '13 at 20:07
  • It seems like this type of thing has been talked about before (based on the findings in the sidekiq.log file) here: https://github.com/gitlabhq/gitlabhq/issues/2747 unfortunately I don't see a resolution... I'll update my OP to include the pertinent parts of the sidekiq.log file. – sadmicrowave Apr 24 '13 at 21:07
  • I had those exact entries in my `sidekiq.log` file, and I remember doing something to fix it... but I don't recall what. It's been over a month now. The bash history isn't helping either. – Steven V Apr 24 '13 at 21:39
  • Dang, this is killing me, I'm somewhat disappointed by the lack of documentation on setting up email notifications with GitLab. This functionality seems like a pretty big deal... – sadmicrowave Apr 25 '13 at 12:17

2 Answers2

8

This is my entries at the end in /config/environment/production.rb and that is working for me.


Comment out sendmail options and use external SMTP relays

  ##config.action_mailer.delivery_method = :sendmail ## Comment out this
  # Defaults to:
  ## config.action_mailer.sendmail_settings = {
  ##   :location => '/usr/sbin/sendmail',
  ##   :arguments => '-i -t'
  ## }

  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true

  ## SMTP Settings
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
      :address => '10.146.10.90', ## My SMTP Relay/Gateway
      :port => 25, ## SMTP Port
      :domain => 'gitlab.example.com', ## My Domain
      :authentication => :plain, ## Let it be plain as it is inside my LAN
      ##:user_name => 'gitlab@yourserver.com', ## This is not required as long as 
      ##:password => 'yourPassword', ## SMTP Gateway allows anonymous relay
      ##:enable_starttls_auto => true ## In LAN
      ##:user_name => '',
      ##:password => '',
      :enable_starttls_auto => true
  }
end

itsadok
  • 28,822
  • 30
  • 126
  • 171
Girish KG
  • 1,074
  • 11
  • 4
  • Thanks for the comment! I implemented the same config that you have and believe it or not I got an email sent out for adding a user (I added myself with a secondary email for testing). But it only happened once, now I can't get anything sent out even if I delete the account in gitlab and add it again I don't get an email...weird – sadmicrowave May 22 '13 at 16:26
  • 1
    Where to find the config file for this? – Leandro Garcia Nov 08 '13 at 19:33
  • @LeandroGarcia by default, it is `/home/git/gitlab/config/environments/production.rb` – ihsan Jan 21 '14 at 02:13
  • As a new gitlab user I'm curious as to when we are supposed to edit this file versus when we are supposed to edit the /etc/gitlab/gitlab.rb file. @sadmicrowave - Same thing is happening to me.. Worked when initially setup and now mysteriously not. I see the remote mail server logging anonymous login attempts from my gitlab server now though isntead of sending through a username – unc0nnected Nov 05 '14 at 21:42
  • --UPDATE: Adding the following into my production.rb file caused my web interface to go down completely and display a 502 error on all pages – unc0nnected Nov 05 '14 at 21:49
  • I have tears in my eyes. – xeed Apr 20 '16 at 10:18
3

On CentOS, this helped for me:

check your file /home/git/gitlab/config/environments/production.rb (if your running on production, wich is standard)

There you can change your sendmail settings. You should try to remove the -t parameter, wich fixed it for me! Some mailservers don't accept this parameter (check your maillog to be sure)

  config.action_mailer.sendmail_settings = {
    :location => '/usr/sbin/sendmail',
    :arguments => '-i'
  }
Roy B.
  • 41
  • 1