gitlab 配置QQ邮箱
gitlab版本
我安装的是ee版11.2.3,跟社区版区别就是有些功能想用的话收费就能用,不想用也没影响,
官方文档
gitlab官方文档有各邮箱详细配置
https://docs.gitlab.com/omnibus/settings/smtp.html
邮箱厂商
本文使用的是QQ邮箱(非企业版)
需要修改的配置文件
/etc/gitlab/gitlab.rb
可以根据自己实际安装目录进行寻找,或使用find name gitlab.rb 查找所在目录
修改的配置内容
gitlab_rails[‘smtp_enable’] = true
gitlab_rails[‘smtp_address’] = “smtp.qq.com”
gitlab_rails[‘smtp_port’] = 465
gitlab_rails[‘smtp_user_name’] = "xxxxxxxx@qq.com"
gitlab_rails[‘smtp_password’] = “aaaabbbbccccdddd”
gitlab_rails[‘smtp_domain’] = “smtp.qq.com”
gitlab_rails[‘smtp_authentication’] = “login”
gitlab_rails[‘smtp_enable_starttls_auto’] = true
gitlab_rails[‘smtp_tls’] = true
gitlab_rails[‘gitlab_email_from’] = "xxxxxxxxxx@qq.com"
gitlab_rails[‘gitlab_email_enabled’] = true
高亮部分项配置只有当smtp_port 为465,启用SSL连接,的时候才会是true,如果端口为25则不需要
另外[‘gitlab_email_from’] 和[‘smtp_user_name’] 必须是一样的否则会报错
调试控制台
gitlab-rails console打开控制台,
输入测试数据 Notify.test_email("wxx729418277@sina.com",“title”,“gitlab”).deliver_now
正确测试结果
[root@xxxxxxxxxxxxxx gitlab]# gitlab-rails console
GitLab: 11.2.3 (06cbee3)
GitLab Shell: 8.1.1
postgresql: 9.6.8[ALoading production environment (Rails 4.2.10)
irb(main):001:0> Notify.test_email("wxx729418277@sina.com",“title”,“gitlab”).deliver_now
Notify#test_email: processed outbound mail in 335.2msSent mail to wxx729418277@sina.com (1169.5ms)
Date: Thu, 06 Dec 2018 15:27:41 +0800
From: GitLab 2501684716@qq.com
Reply-To: GitLab noreply@47.99.69.111
To: wxx729418277@sina.com
Message-ID: 5c08cf6de702_7653fa6273daf8815493@izbp1hw7653yyqia9yf9y6z.mail
Subject: title
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Auto-Submitted: auto-generated
X-Auto-Response-Suppress: All
<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN” "http://www.w3.org/TR/REC-
<html><body><p>gitlab</p></body></html>
=> #<Mail::Message:69982501656780, Multipart: false, Headers: <Date: Thu, 06 Dec 2018 15yyqia9yf9y6z.mail>>, <Subject: title>, <Mime-Version: 1.0>, <Content-Type: text/html; ch
irb(main):002:0> exit
参照链接来源: 翛宸-gitlab 邮件服务器配置.