这篇文章主要介绍一下gitlab中如何进行邮件的配置,并使用163邮箱进行验证。
设定文件
可以通过直接设定环境变量或者修正gitlab.rb的方式来设定,本文使用直接设定gitlab.rb文件方式。
设定文件所在目录gitlab.rb
/etc/gitlab
修改内容
修改如下内容(对应的xx相关内容使用自己的邮箱地址,注意邮箱此处需要一致)
gitlab_rails['gitlab_email_from'] = 'xxxxxxxx@163.com'
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.163.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "xxxxxxxx@163.com"
gitlab_rails['smtp_password'] = "xxxxxx"
gitlab_rails['smtp_domain'] = "163.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = false
gitlab_rails['smtp_openssl_verify_mode'] = 'peer'
user['git_user_email'] = "xxxxxxxx@163.com"
修改起效
修改了gitlab.rb文件,可以使用如下命令使其生效。
gitlab-ctl reconfigure
执行log
# gitlab-ctl reconfigure
Starting Chef Client, version 12.12.15
resolving cookbooks for run list: ["gitlab"]
Synchronizing Cookbooks:
- runit (0.14.2)
- package (0.0.0)
- gitlab (0.0.1)
Installing Cookbook Gems:
Compiling Cookbooks...
...
@@ -4,7 +4,7 @@
[user]
name = GitLab
- email = gitlab@22bab50a8878
...
[core]
autocrlf = input
[gc]
Recipe: gitlab::gitlab-shell
...
@@ -1 +1,24 @@
+# This file is managed by gitlab-ctl. Manual changes will be
+# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
+# and run `sudo gitlab-ctl reconfigure`.
+
+if Rails.env.production?
+ Gitlab::Application.config.action_mailer.delivery_method = :smtp
+
+ ActionMailer::Base.delivery_method = :smtp
+ ActionMailer::Base.smtp_settings = {
+ authentication: :login,
+ address: "smtp.163.com",
+ port: 25,
...
+ domain: "163.com",
+ enable_starttls_auto: false,
+
+
+ openssl_verify_mode: "peer",
+
+ ca_file: "/opt/gitlab/embedded/ssl/certs/cacert.pem",
+ }
+end
- change mode from '' to '0644'
- change owner from '' to 'root'
- change group from '' to 'root'
* link[Link /opt/gitlab/embedded/service/gitlab-rails/config/initializers/smtp_settings.rb
...
Running handlers:
Running handlers complete
Chef Client finished, 9/275 resources updated in 35 seconds
gitlab Reconfigured!
#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
创建一个用户
输入实际的email创建用户,此邮箱可以收到一封mail,此mail中包含初次登陆时可以进行密码设
定的链接。
log确认
可以使用gitlab-ctl tail确认输出的日志,对问题的确认和定位很有帮助。在其中发现了发向liumiaocn@outlook.com的发送mail的信息提示。
==> /var/log/gitlab/gitlab-rails/production.log <==
[ActiveJob] [ActionMailer::DeliveryJob] [7671429f-3416-446f-8a0d-63733c7bc71d]
Sent mail to liumiaocn@outlook.com (921.0ms)
[ActiveJob] [ActionMailer::DeliveryJob] [7671429f-3416-446f-8a0d-63733c7bc71d] Performed ActionMailer::DeliveryJob from Sidekiq(mailers) in 1069.46ms
mail确认
确实已经收到邮件。
容易出现的问题
邮件配置的时候容易出现”smtp sever reply:553 mail from must equal authorized user”的提示,这是因为设置的用户和实际发送邮件的用户不一致所致,因为default的邮箱需要重新设定一下,gitlab_email_from一定不要忘记设定。
总结
通过设定gitlab.rb,使用gitlab-ctl reconfigure使其生效,创建用户时就能确认是否能够收到email了。
http://www.woaipu.com/shops/zuzhuan/61406
http://www.znds.com/tv-967956-1-1.html
http://www.znds.com/tv-967958-1-1.html
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com