项目组需求 需要gitlab配置SMTP发送邮件 此文档做个记录

gitlab已经安装安装好电梯直达

配置SMTP

  • 找到gitlab的gitlab.rb文件挂载位置,编辑gitlab.rb文件
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
......

###! **Use smtp instead of sendmail/postfix.**

 gitlab_rails['smtp_enable'] = true
 gitlab_rails['smtp_address'] = "smtp.qiye.163.com" ## 此处要改成你的smtp地址
 gitlab_rails['smtp_port'] = 25
 gitlab_rails['smtp_user_name'] = "dev_admin@XXX.com" ## 此处改成你的邮箱
 gitlab_rails['smtp_password'] = "nyp3RszuNqGJ47py" #这里是授权码
 gitlab_rails['smtp_domain'] = "qiye.163.com" ## smtp地址域名
 gitlab_rails['smtp_authentication'] = "login"
 gitlab_rails['smtp_enable_starttls_auto'] = true
 gitlab_rails['smtp_tls'] = false

 gitlab_rails['gitlab_email_from'] = "dev_admin@XXX.com"   ## 发件邮箱
 user["git_user_email"] = "dev_admin@XXX.com" 
 #其中smtp_user_name和gitlab_email_from需要修改为真实的邮箱
 ......
  • 配置后重启gitlab
1
docker restart gitlab

验证SMTP

1
2
3
4
5
6
7
gitlab-rails console 
# 确保method为smtp
ActionMailer::Base.delivery_method
# 确认配置
ActionMailer::Base.smtp_settings
# 测试发送邮件
Notify.test_email('xxx@yyy.com','测试标题','测试内容').deliver_now