gitlab配置邮件通知功能操做记录

 

以前已经介绍了gitlab的部署http://www.cnblogs.com/kevingrace/p/5651402.html
可是没有配置邮箱通知功能,今天这里介绍下gitlab安装后的邮箱配置操做:html

注意几点:
1)登录gitlab后,只能在admin管理员帐号下建立新帐号,通常来讲,建立好新帐号后,会自动给新帐号预留的邮箱发送通知邮件,点击邮件中的连接进行激活,首次登录gitlab会进行密码设置。
2)若是不想在通知邮件里修改密码或没收到邮件,也能够绕过这一步。即在新帐号建立后,在管理员状态下“编辑”新帐号,设置一个密码,这个是初始密码。而后登录新帐号,这时候登录后会强制进行初始密码的修改。git

邮箱通知功能开通后,除了上面能够发送新建帐号的激活邮件,还能够让用户经过邮箱注册gitlab,而后在管理员帐号下对新注册帐号进行project和group等权限授予。
这个有点不太安全,后续会介绍gitlab+openldap对接的操做记录,跟openldap结合后,gitlab的登录就只能是LDAP方式了,邮箱注册功能就会失效!vim

废话很少说了,下面是gitlab开通邮箱通知功能的操做记录:安全

这里测试使用的是阿里云的企业邮箱
假设通知邮件的邮箱名为ops@wangshibo.cn,密码为zh@123bj
主要修改gitlan的三个文件,邮箱相关设置以下:
1)编辑/opt/gitlab-8.8.4-0/apps/gitlab/htdocs/config/gitlab.yml文件,开通email邮件功能
[root@test-huanqiu ~]# vim /opt/gitlab-8.8.4-0/apps/gitlab/htdocs/config/gitlab.yml
.........
email_enabled: true
# Email address used in the "From" field in mails sent by GitLab
email_from: ops@wangshibo.cn
#email_display_name: GitLab
#email_reply_to: noreply@example.com
........app

2)编辑/opt/gitlab-8.8.4-0/apps/gitlab/htdocs/config/initializers/smtp_settings.rb.sample文件
[root@test-huanqiu ~]# vim /opt/gitlab-8.8.4-0/apps/gitlab/htdocs/config/initializers/smtp_settings.rb.sample
........
ActionMailer::Base.smtp_settings = {
address: "smtp.wangshibo.cn",
port: 25,
user_name: "ops@wangshibo.cn",
password: "zh@123bj",
domain: "wangshibo.cn",
authentication: :login,
enable_starttls_auto: true,
openssl_verify_mode: 'none' # See ActionMailer documentation for other possible options
}
.......dom

3)编辑/opt/gitlab-8.8.4-0/apps/gitlab/htdocs/config/environments/production.rb文件,添加下面标红的几行内容,设置smtp模式
[root@test-huanqiu ~]# vim /opt/gitlab-8.8.4-0/apps/gitlab/htdocs/config/environments/production.rb
.......
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.wangshibo.cn",
:port => "25",
:domain => "wangshibo.cn",
:authentication => :plain,
:user_name => "ops@wangshibo.cn",
:password => "zh@123bj",
:enable_starttls_auto => true
}gitlab

config.eager_load = true测试

config.allow_concurrency = false
.......阿里云

最后,重启gitlab相关服务
[root@localhost gitlab-8.8.4-0]# pwd
/opt/gitlab-8.8.4-0
[root@localhost gitlab-8.8.4-0]# ./ctlscript.sh restartspa

------------------------------------------------------------------------
下面是腾讯企业邮箱的一个配置:
假设腾讯企业邮箱是:noreply@wangshibo.com,密码是H8*Cy9wXn8$SuhbT
1)gitlab.yml文件配置
......
email_enabled: true
# Email address used in the "From" field in mails sent by GitLab
email_from: noreply@wangshibo.com
#email_display_name: GitLab
#email_reply_to: noreply@wangshibo.com
......
2)smtp_settings.rb 文件配置
.....
ActionMailer::Base.smtp_settings = {
address: "smtp.exmail.qq.com",
port: 25,
user_name: "noreply@wangshibo.com",
password: "H8*Cy9wXn8$SuhbT",
domain: "smtp.qq.com",
authentication: :plain,
enable_starttls_auto: true,
openssl_verify_mode: 'none' # See ActionMailer documentation for other possible options
}
3)production.rb文件配置
......
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.exmail.qq.com",
:port => "25",
:domain => "smtp.qq.com",
:authentication => :plain,
:user_name => "noreply@wangshibo.com",
:password => "H8*Cy9wXn8$SuhbT",
:enable_starttls_auto => true
}

config.eager_load = true

config.allow_concurrency = false

相关文章
相关标签/搜索