ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

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

2021-04-10 19:05:01  阅读:234  来源: 互联网

标签:wangshibo 记录 com gitlab smtp 8.8 config 邮件


之前已经介绍了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

标签:wangshibo,记录,com,gitlab,smtp,8.8,config,邮件
来源: https://blog.51cto.com/u_10272167/2698023

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有