之前已經介紹了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