Gitlab配置邮件服务【第三步】

配置邮件服务

1.打开配置文件

vi /etc/gitlab/gitlab.rb

2.修改external_url

# 这里配置为能正确访问到你的gitlab的地址
external_url'http://123.207.*.*/'

3.修改邮件配置

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.126.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "xxxx@126.com"
gitlab_rails['smtp_password'] = "xxxxxx"
# gitlab_rails['smtp_domain'] = "126.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false

这里我用的是126的邮箱,其他邮箱可能不太一样

2.修改gitlab配置的发信人(发送邮件的邮箱)

gitlab_rails['gitlab_email_from'] = "xxxx@126.com"
user["git_user_email"] = "xxxx@126.com"

这里两个地址一定要设置一样的,否则会出现邮件发送不过来的现象

3.当修改完成后, 记得重新加载配置并重启

# 重新加载配置
gitlab-ctl reconfigure
# 重启服务
gitlab-ctl restart

4.测试

忘记密码就可以,看邮件是否发送过来
# 你也可以通过下面的命令去看监听日志
gitlab-ctl tail
==> /var/log/gitlab/gitlab-rails/production.log <==
Started POST "/users/password" for 106.37.114.223 at 2018-04-20 20:35:15 +0800
Processing by PasswordsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"[FILTERED]", "user"=>{"email"=>"3211028@qq.com"}}