sameersbn / docker-gitlab

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

SMTP does not work #118

Closed johnjelinek closed 10 years ago

johnjelinek commented 10 years ago

Even with STMP settings set, production.rb still says sendmail.

docker run -it --rm --link postgresql:postgresql --link redis:redisio \
-e 'GITLAB_PROJECTS_VISIBILITY=public' -e 'GITLAB_PORT=80' \
-e 'GITLAB_SSH_PORT=2222' -e 'NGINX_MAX_UPLOAD_SIZE=800m' \
-e 'DB_USER=git' -e 'DB_PASS=password' -e 'SMTP_DOMAIN=www.example.com' \
-e 'SMTP_HOST=smtp.example.com' -e 'SMTP_PORT=25' \
-e 'SMTP_AUTHENTICATION=none' -v /opt/gitlab/data:/home/git/data sameersbn/gitlab:7.1.1 bash
 root@gitlab:/home/git/gitlab# grep mailer config/environments/production.rb
  # config.action_mailer.raise_delivery_errors = false
  config.action_mailer.delivery_method = :sendmail
  # # config.action_mailer.sendmail_settings = {
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
sameersbn commented 10 years ago

@johnjelinek please check the config/initializers/smtp_settings.rb file for the smtp configuration.

johnjelinek commented 10 years ago
address: "smtp.example.com",
    port: 25,
    domain: "www.example.com",
    authentication: "none",
    enable_starttls_auto: true

This is what I see (I replaced the address and domain with fake values here). The only difference here is that, I see authentication: :none in my 6.5.1 instance where e-mail works.

johnjelinek commented 10 years ago

6.5.1

# cat config/initializers/smtp_settings.rb
# To enable smtp email delivery for your GitLab instance do next:
# 1. Change config/environments/production.rb to use smtp
#    config.action_mailer.delivery_method = :smtp
# 2. Rename this file to smtp_settings.rb
# 3. Edit settings inside this file
# 4. Restart GitLab instance
#
if Gitlab::Application.config.action_mailer.delivery_method == :smtp
  ActionMailer::Base.smtp_settings = {
    address: "smtp.example.com",
    port: 25,
    # user_name: "smtp",
    # password: "123456",
    domain: "www.example.com",
    authentication: :none,
    enable_starttls_auto: true
  }
end

7.1.1

# cat config/initializers/smtp_settings.rb
# To enable smtp email delivery for your GitLab instance do next:
# 1. Rename this file to smtp_settings.rb
# 2. Edit settings inside this file
# 3. Restart GitLab instance
#
if Rails.env.production?
  Gitlab::Application.config.action_mailer.delivery_method = :smtp

  ActionMailer::Base.smtp_settings = {
    address: "smtp.example.com",
    port: 25,
    domain: "www.example.com",
    authentication: "none",
    enable_starttls_auto: true
  }
end
sameersbn commented 10 years ago

@johnjelinek the newer actionmail has dropped the : character from the authentication parameter. :none now becomes none, at least that is the case for login. Since you do not require authentication, you can just drop the -e "SMTP_AUTHENTICATION=none" parameter from the run command.

sameersbn commented 10 years ago

@johnjelinek If it does not help. Then you can enter the container (nsenter/nsinit) and try to manually update the config/initializers/smtp_settings.rb. You can reload the unicorn server by executing kill -s USR2 $(cat /home/git/gitlab/tmp/pids/unicorn.pid). Once you get the mailer working let me know the changes and lets try to incorporate them into the image.

johnjelinek commented 10 years ago

ok, I think I'm going to try to jump in with nsinit and change config.action_mailer.delivery_method = :sendmail to config.action_mailer.delivery_method = :smtp in config/environments/production.rb

sameersbn commented 10 years ago

@johnjelinek I think you need to change it in the config/initializers/smtp_settings.rb since any configs in the initializers folder override other configs. Or you can just remove the config/initializers/smtp_settings.rb file first.

johnjelinek commented 10 years ago

Even though the production.rb says changes there take precedence? https://github.com/gitlabhq/gitlabhq/blob/master/config/environments/production.rb#L2

sameersbn commented 10 years ago

@johnjelinek ok.. maybe your right

johnjelinek commented 10 years ago

hmm .. modifying the config.action_mailer.delivery_method didn't seem to resolve it. Any thoughts? Does SMTP work for you?

johnjelinek commented 10 years ago

Maybe I'm not issuing commands that would send out e-mails? In 6.5.1, whenever I create a repo I'd get an e-mail.

johnjelinek commented 10 years ago

lol, nvm -- I wasn't doing any actions that were causing e-mails to get sent. SMTP works when you do something like creating a new user. No special changes necessary.

sameersbn commented 10 years ago

@johnjelinek haha... so you were able to use the existing config options to get the mailer working right?

johnjelinek commented 10 years ago

Yup, no changes. On Aug 6, 2014 2:33 AM, "Sameer Naik" notifications@github.com wrote:

@johnjelinek https://github.com/johnjelinek haha... so you were able to use the existing config options to get the mailer working right?

— Reply to this email directly or view it on GitHub https://github.com/sameersbn/docker-gitlab/issues/118#issuecomment-51302504 .

hsitaa commented 8 years ago

Its not Working. Specified the conf. Do i need to expose any port in Docker compose yml.

my Host machine : Centos7 running it on Docker for gitlab,

mails are working for Host machine. But when try to send mail from gitlab. Nothing happens.

1.) Do i need to install postfix on Docker machine? 2.) Do i need to expose any port. 3.) Tried using Gmail smtp as well as extrernal mailserver. : Which 1 suggested?

sameersbn commented 8 years ago

@hsitaa please create a new issue report.