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

2018-01-23 10:56:45 浏览数 (1)

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

注意几点: 1)登陆gitlab后,只能在admin管理员账号下创建新账号,一般来说,创建好新账号后,会自动给新账号预留的邮箱发送通知邮件,点击邮件中的链接进行激活,首次登陆gitlab会进行密码设置。 2)如果不想在通知邮件里修改密码或没收到邮件,也可以绕过这一步。即在新账号创建后,在管理员状态下“编辑”新账号,设置一个密码,这个是初始密码。然后登陆新账号,这时候登陆后会强制进行初始密码的修改。

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

废话不多说了,下面是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 ........

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 } .......

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 }

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 restart

------------------------------------------------------------------------ 下面是腾讯企业邮箱的一个配置: 假设腾讯企业邮箱是: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

0 人点赞