Gitlab配置阿里郵件通知

1. 在/etc/gitlab/gitlab.rb 中添加以下內容html

$ vi /etc/gitlab/gitlab.rbgit

  gitlab_rails['smtp_enable'] = true
  gitlab_rails['smtp_address'] = "smtp.mxhichina.com"
  gitlab_rails['smtp_port'] = 80
  gitlab_rails['smtp_user_name'] = "notice@idba.cn"  
  gitlab_rails['smtp_password'] = "password"
  gitlab_rails['smtp_domain'] = "smtp.mxhichina.com"
  gitlab_rails['smtp_authentication'] = "plain"
  gitlab_rails['smtp_enable_starttls_auto'] = true安全

 

2. 保存配置文件後執行如下命令dom

$ gitlab-ctl reconfigure gitlab

 

3. 發送測試郵件,檢查郵件配置是否有問題測試

$ gitlab-rails console 
irb(main):001:0> Notify.test_email('resn@idba.cn', 'Message Subject test', 'Message Body test').deliver_now阿里雲

紅色部分爲console提示符出現後要執行的命令htm

 

注意:ci

gitlab_rails['smtp_port'] =465  #465端口會致使發送郵件的時候報錯一個錯誤 :EOFError: end of file reached 部署

gitlab_rails['smtp_port'] =25  # 網上找了好幾篇文章都說設置爲25端口能夠解決 EOFError: end of file reached 的問題, 但設置爲25會報錯 Errno::ETIMEDOUT: Connection timed out - connect(2) for "smtp.mxhichina.com" port 25 

最後發現,阿里基於安全考慮,目前已禁用 25 端口。

若是您的發送程序部署在阿里雲 ECS 上,建議您不勾選 SSL 時,使用 80 端口;勾選 SSL 時,使用 465 端口。

參考連接:https://help.aliyun.com/document_detail/29449.html

相關文章
相關標籤/搜索