这篇文章主要介绍一下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
# 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!
#
输入实际的email创建用户,此邮箱可以收到一封mail,此mail中包含初次登陆时可以进行密码设
定的链接。
可以使用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
确实已经收到邮件。
邮件配置的时候容易出现”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
原文:http://www.cnblogs.com/sy646et/p/7198102.html