cfsky 发表于 2018-9-19 11:18:45

Gitlab邮件配置

  git+gitlab安装好后邮件默认发出地址是gitlab@localhost ,此地址会被任何邮件服务商都拦截,且无法加入白名单。


  
  配置gitlab用smtp发送邮件(网上参考大多都不靠谱),最终测试以下三步就可以了:
  1. 修改全局配置文件git/.gitconfig文件,这里的email是gitlab发送邮件的Email地址
  
  name = GitLab
  email = gitlab@olymtech.com
  2. 配置gitlab的发送邮件的SMTP服务
  修改gitlab/config/environments/production.rb配置文件:
  config.action_mailer.delivery_method= :smtp
  更改smtp邮件配置文件gitlab/config/initializers/smtp_settings.rb:
  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

页: [1]
查看完整版本: Gitlab邮件配置