Gitlab郵件配置

git+gitlab安裝好後郵件默認發出地址是gitlab@localhost ,此地址會被任何郵件服務商都攔截,且沒法加入白名單。git

wKioL1TQeCiBNBgEAAC-nEl-NKQ668.jpg

wKiom1TQdz_SnOk8AAD-1P18U28573.jpg


配置gitlab用smtp發送郵件(網上參考大多都不靠譜),最終測試如下三步就能夠了:服務器

1. 修改全局配置文件git/.gitconfig文件,這裏的email是gitlab發送郵件的Email地址
dom

[user]ide

        name = GitLabgitlab

        email = gitlab@olymtech.com測試

2. 配置gitlab的發送郵件的SMTP服務加密

修改gitlab/config/environments/production.rb配置文件:url

config.action_mailer.delivery_method= :smtpspa

更改smtp郵件配置文件gitlab/config/initializers/smtp_settings.rbblog

if Gitlab::Application.config.action_mailer.delivery_method == :smtp 
ActionMailer::Base.smtp_settings = { 
address: "smtp.exmail.qq.com", 
port: 25, 
user_name: "
gitlab@olymtech.com", 
password: "123456", 
domain: "mail.qq.com", 
authentication: 'plain', 
enable_starttls_auto: false 

end

若是沒用smtp沒有開加密鏈接的話 enable_starttls_auto 的值應該配置爲 false

3. 須要注意一個問題, 若是你的smtp服務器作了權限限制,只能以登錄帳戶的郵件賬號發郵件的話,還須要修改gitlab/config/gitlab.yml   

email_from: gitlab@olymtech.com

support_email: gitlab@olymtech.com


以後發送出來的郵件仍是以gitlab@localhost郵件格式發出,最後 gitlab/config/environments/development.rb在此配置文件中發現這麼一段:

 # For having correct urls in mails

  config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }

將localhost改爲個人發件箱後綴olymtech.com 

再次重啓gitlab服務,測試郵件OK。


切記開設防火牆的話,本地迴環地址必定要開放。

ufw allow from 127.0.0.1

相關文章
相關標籤/搜索