邮箱是企业进行工作中的通知,交互必不可少的部分,gitlab同样支持邮箱的配置,方便对一些操作有邮件的提醒,本文以QQ邮箱为例,进行gitlab邮箱的添加。

一、开启smtp功能

登陆邮箱==》设置==》账户==》POP3/IMAP/SMTP/Exchange/CardDAV/CalDAV服务==》开启SMTP服务==》接收验证

1.png

2.png

3.png


二、修改配置文件

[root@localhost opt]# grep -rn "^[^#]" /etc/gitlab/gitlab.rb 

13:external_url 'http://192.168.0.8:81'

57:gitlab_rails['gitlab_email_from'] = 'w135xxx@qq.com'

58:gitlab_rails['smtp_enable'] = true

59:gitlab_rails['smtp_address'] = "smtp.qq.com"

60:gitlab_rails['smtp_port'] = 465

61:gitlab_rails['smtp_user_name'] = "w135xxx@qq.com"

62:gitlab_rails['smtp_password'] = "cknzlfrvhwmbbagf"

63:gitlab_rails['smtp_domain'] = "smtp.qq.com"

64:gitlab_rails['smtp_authentication'] = "login"

65:gitlab_rails['smtp_enable_starttls_auto'] = true

66:gitlab_rails['smtp_tls'] = true


三、加载配置文件并重启gitlab

[root@localhost opt]#  gitlab-ctl reconfigure

[root@localhost opt]#  gitlab-ctl restart


四、验证

[root@localhost opt]#  gitlab-rails console 

irb(main):001:0> 

Notify.test_email('232xxxx@qq.com', 'GitLab email', 'Hellow world').deliver_now

Notify#test_email: processed outbound mail in 363.2ms

Sent mail to 232xxxx@qq.com (1902.1ms)

Date: Wed, 13 Feb 2019 10:21:31 +0800

From: GitLab <w135xxxx@qq.com>

Reply-To: GitLab <noreply@192.168.0.8>

To: 232xxxx@qq.com

最后去邮箱中查看结果即可,以上操作皆验证测试成功。