sameersbn / docker-gitlab

Dockerized GitLab
http://www.damagehead.com/docker-gitlab/
MIT License
7.9k stars 2.14k forks source link

Cannot receive email after setup gamil IMAP in env #596

Open atom2ueki opened 8 years ago

atom2ueki commented 8 years ago
2016-02-05 13:20:14,231 INFO exited: mail_room (exit status 1; not expected)
2016-02-05 13:20:15,239 INFO spawned: 'mail_room' with pid 688
2016-02-05 13:20:16,242 INFO success: mail_room entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

this is the logs from gitlab

atom2ueki commented 8 years ago

seems this build didn't expose all the configure for mailing

config.action_mailer.smtp_settings = {  
  :address              => "smtp.mailgun.org",
  :port                 => 587,
  :domain               => 'gitlab.mydomain.com',
  :user_name            => 'user@mydomain.org',
  :password             => 'password',
  :authentication       =>  :plain,
  :enable_starttls_auto => true
}
atom2ueki commented 8 years ago

My bad, just put those variables when running docker can do.

--env 'SMTP_HOST=smtp.mailgun.org' \
--env 'SMTP_DOMAIN=domain' \
--env 'SMTP_USER=username' \
--env 'SMTP_PASS=password' \ 
sameersbn commented 8 years ago

SMTP settings are for mail sending. the IMAP settings are for incoming mails.

waterdrops commented 8 years ago

i met the same issue, log info: 2016-06-15 15:48:04,593 INFO success: mail_room entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) 2016-06-15 15:48:05,508 INFO exited: mail_room (exit status 1; not expected) 2016-06-15 15:48:06,510 INFO spawned: 'mail_room' with pid 590 2016-06-15 15:48:07,511 INFO success: mail_room entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

SMTP & IMAP configuration file:

- IMAP_ENABLED=true
- IMAP_HOST=192.168.1.1
- IMAP_PORT=993
- IMAP_USER=username
- IMAP_PASS=passwd
- IMAP_SSL=true
- IMAP_STARTTLS=false
klinsmaya commented 8 years ago

the same problem happened in version 8.8.3.

SMTP & IMAP configuration value:

SMTP_HOST=mail.xx..com
SMTP_USER=pby@xx..com
SMTP_PASS=xx@xx
IMAP_USER=pby@xx.com
IMAP_PASS=xx@xx
IMAP_HOST=mail.xx..com
globalcitizen commented 7 years ago

Same on 8.14.3.

How to debug?

Same IMAP credentials work fine via fetchmail.

Hrrm - OK, I got somewhere.

First I found the container ID...

$ docker ps

Then I ran a shell...

$ docker exec -it container_id_goes_here bash

Then I searched for the appropriate restarting process...

root@container_id:/home/git/gitlab# ps aux |grep -i mail
git        615  0.0  0.0  56068 10764 ?        Rl   11:25   0:00 /usr/bin/ruby2.3 /usr/local/bin/bundle exec mail_room -c /home/git/gitlab/config/mail_room.yml
root       618  0.0  0.0   8872   612 ?        S+   11:25   0:00 grep --color=auto -i mail
root@container_id:/home/git/gitlab#

Then I tried to run it manually, and after a few seconds it dumped out with this error.

# /usr/bin/ruby2.3 /usr/local/bin/bundle exec mail_room -c /home/git/gitlab/config/mail_room.yml/usr/lib/ruby/2.3.0/openssl/ssl.rb:315:in `post_connection_check': hostname "imap.mydomain" does not match the server certificate (OpenSSL::SSL::SSLError)
    from /usr/lib/ruby/2.3.0/net/imap.rb:1494:in `start_tls_session'
    from /usr/lib/ruby/2.3.0/net/imap.rb:1085:in `initialize'
    from /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/mail_room-0.9.0/lib/mail_room/connection.rb:74:in `new'
    from /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/mail_room-0.9.0/lib/mail_room/connection.rb:74:in `imap'
    from /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/mail_room-0.9.0/lib/mail_room/connection.rb:84:in `log_in'
    from /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/mail_room-0.9.0/lib/mail_room/connection.rb:68:in `setup'
    from /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/mail_room-0.9.0/lib/mail_room/connection.rb:8:in `initialize'
    from /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/mail_room-0.9.0/lib/mail_room/mailbox_watcher.rb:57:in `new'
    from /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/mail_room-0.9.0/lib/mail_room/mailbox_watcher.rb:57:in `connection'
    from /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/mail_room-0.9.0/lib/mail_room/mailbox_watcher.rb:28:in `run'
    from /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/mail_room-0.9.0/lib/mail_room/coordinator.rb:19:in `each'
    from /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/mail_room-0.9.0/lib/mail_room/coordinator.rb:19:in `run'
    from /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/mail_room-0.9.0/lib/mail_room/cli.rb:52:in `start'
    from /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/mail_room-0.9.0/bin/mail_room:5:in `<top (required)>'
    from /home/git/gitlab/vendor/bundle/ruby/2.3.0/bin/mail_room:23:in `load'
    from /home/git/gitlab/vendor/bundle/ruby/2.3.0/bin/mail_room:23:in `<main>'
root@3324f228a398:/home/git/gitlab#

It looks like in my case, the connection does not work because the server's SSL certificate does not match the domain name. This is sort of lame as it is the sort of error that should bubble out to the environment somehow.

I found a website over here explaining how to dump SSL details, then adapted the command to port 993 of the IMAP server in question...

# echo | openssl s_client -showcerts -servername myserver -connect myserver:993 2>/dev/null | openssl x509 -inform pem -noout -text

This showed on the very first Subject: line that CN=*.ourisp.domain ... where CN means 'Canonical Name' and basically means the server is identifying itself as the ISP, not the domain we use for email. Therefore I did the following...

$ nslookup imap.ourdomain
Non-authoritative answer:
imap.ourdomain  canonical name = imap.ourisp.domain.

This suggests that the IP address is actually also possible to reference as imap.ourisp.domain..

So I will delete my entire setup and retry with this domain as the server setting instead, and see how it goes. Same for SMTP.

OK, so I pressed CTRL+C to break out of the docker-compose session then ran docker-compose rm to remove the associated data volumes.

Then I edited my docker-compose.yml file to change the domain names, then re-ran docker-compose up.

It now seems to run without the constantly re-spawning mail_room process, so it seems this solved the issue.

globalcitizen commented 7 years ago

Update: I am still seeing similar errors occasionally.

I found /var/log/gitlab/gitlab/mail_room.log contains the full contents of the output of the mail_room script in the event of errors.

This is what you should check to determine what the cause of your errors is.

In my case the occasional errors were instances of...

/usr/lib/ruby/2.3.0/openssl/buffering.rb:57:in `sysread': Connection reset by peer (Errno::ECONNRESET)
    from /usr/lib/ruby/2.3.0/openssl/buffering.rb:57:in `fill_rbuff'
    from /usr/lib/ruby/2.3.0/openssl/buffering.rb:204:in `gets'
    from /usr/lib/ruby/2.3.0/net/imap.rb:1207:in `get_response'
    from /usr/lib/ruby/2.3.0/net/imap.rb:1129:in `receive_responses'
    from /usr/lib/ruby/2.3.0/net/imap.rb:1111:in `block in initialize'

... which sounds like the server in question was down for awhile.

globalcitizen commented 7 years ago

@sameersbn Maybe you should take another look at this. I think virtually hosted email domains on many ISPs probably have this issue.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had any activity for the last 60 days. It will be closed if no further activity occurs during the next 7 days. Thank you for your contributions.