以前已經介紹了gitlab的部署http://www.cnblogs.com/kevingrace/p/5651402.html
可是沒有配置郵箱通知功能,今天這裏介紹下gitlab安裝後的郵箱配置操做:html
注意幾點:
1)登錄gitlab後,只能在admin管理員帳號下建立新帳號,通常來講,建立好新帳號後,會自動給新帳號預留的郵箱發送通知郵件,點擊郵件中的連接進行激活,首次登錄gitlab會進行密碼設置。
2)若是不想在通知郵件裏修改密碼或沒收到郵件,也能夠繞過這一步。即在新帳號建立後,在管理員狀態下「編輯」新帳號,設置一個密碼,這個是初始密碼。而後登錄新帳號,這時候登錄後會強制進行初始密碼的修改。git
郵箱通知功能開通後,除了上面能夠發送新建帳號的激活郵件,還能夠讓用戶經過郵箱註冊gitlab,而後在管理員帳號下對新註冊帳號進行project和group等權限授予。
這個有點不太安全,後續會介紹gitlab+openldap對接的操做記錄,跟openldap結合後,gitlab的登錄就只能是LDAP方式了,郵箱註冊功能就會失效!vim
廢話很少說了,下面是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
........app
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
}
.......dom
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
}gitlab
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 restartspa
------------------------------------------------------------------------
下面是騰訊企業郵箱的一個配置:
假設騰訊企業郵箱是: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