Gitlab配置阿里邮件通知

1. 在/etc/gitlab/gitlab.rb 中添加如下内容

$ vi /etc/gitlab/gitlab.rb

  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. 保存配置文件后执行以下命令

$ gitlab-ctl reconfigure 

 

3. 发送测试邮件,检查邮件配置是否有问题

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

红色部分为console提示符出现后要执行的命令

 

注意:

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

 

posted on 2018-09-13 10:38  R_e  阅读(1570)  评论(0编辑  收藏  举报

导航