GitLab on Docker 配置 SMTP 服务

起因

gitlab 官方 docker 容器部署完毕。容器中的服务越少越好,所以使用外部 SMTP 发送邮件。

环境

撰写此文时:

  • Docker 17.06.1-ce
  • GitLab Community Edition 9.5.2 ab97415

步骤

网易 163 邮箱

授权码设置

协议开启与服务器地址

容器中的 /etc/gitlab/gitlab.rb

 1### Email Settings
 2# gitlab_rails['gitlab_email_enabled'] = true
 3gitlab_rails['gitlab_email_from'] = '<yourname>@163.com'
 4# gitlab_rails['gitlab_email_display_name'] = 'Example'
 5# gitlab_rails['gitlab_email_reply_to'] = 'noreply@example.com'
 6# gitlab_rails['gitlab_email_subject_suffix'] = ''
 7gitlab_rails['smtp_enable'] = true
 8gitlab_rails['smtp_address'] = "smtp.163.com"
 9gitlab_rails['smtp_port'] = 994
10gitlab_rails['smtp_user_name'] = "<yourname>@163.com"
11gitlab_rails['smtp_password'] = "<your 163 auth code>"
12gitlab_rails['smtp_domain'] = "163.com"
13gitlab_rails['smtp_authentication'] = :login
14gitlab_rails['smtp_enable_starttls_auto'] = false
15gitlab_rails['smtp_tls'] = true
16###! **Can be: 'none', 'peer', 'client_once', 'fail_if_no_peer_cert'**
17###! Docs: http://api.rubyonrails.org/classes/ActionMailer/Base.html
18gitlab_rails['smtp_openssl_verify_mode'] = 'peer'

注意事项

gitlab_rails['gitlab_email_from']gitlab_rails['smtp_user_name'] 一致

以下三项:改变其中一项设置,其他项需匹配

  • gitlab_rails['smtp_enable_starttls_auto'] = false
  • gitlab_rails['smtp_tls'] = true
  • gitlab_rails['smtp_port'] = 994

配置完毕:

1gitlab-ctl reconfigure

参考

https://docs.gitlab.com/omnibus/docker/README.html

https://docs.gitlab.com/omnibus/settings/smtp.html

http://wap.mail.163.com/xm/static/html/163_symbian_2.html


本文采用 知识共享署名许可协议(CC-BY 4.0)进行许可,转载注明来源即可。如有错误劳烦评论或邮件指出。


comments powered by Disqus