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

一、开启smtp功能

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

gitlab添加邮箱设置_第1张图片

gitlab添加邮箱设置_第2张图片

gitlab添加邮箱设置_第3张图片


二、修改配置文件

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

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

57:gitlab_rails['gitlab_email_from'] = '[email protected]'

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'] = "[email protected]"

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('[email protected]', 'GitLab email', 'Hellow world').deliver_now

Notify#test_email: processed outbound mail in 363.2ms

Sent mail to [email protected] (1902.1ms)

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

From: GitLab

Reply-To: GitLab

To: [email protected]

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