Gitlab 11.1.4 配置SMTP邮箱服务器 | IT运维网
  • 欢迎访问本网站;本站QQ交流群:654792529;如果您觉得本站非常有看点,那么赶紧使用Ctrl+D收藏吧!
  • 本站为个人技术性博客网站,上面会更新一些系统、网络、云计算和监控等相关运维的技术性文章,供大家参考、学习和一起交流。

Gitlab 11.1.4 配置SMTP邮箱服务器

Gitlab yvan 1年前 (2018-08-08) 2586次浏览 已收录 0个评论 扫描二维码

说明:Gitlab可以配置外部SMTP邮箱服务器来实现内部邮件提醒功能,此处我们演示的是阿里云免费企业邮(mxhichina.com)SMTP邮箱服务器。

1、编辑修改配置文件/etc/gitlab/gitlab.rb定义SMTP参数

gitlab_rails['gitlab_email_from'] = 'postmaster@ityww.cn'
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.mxhichina.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "postmaster@ityww.cn"
gitlab_rails['smtp_password'] = "password"
gitlab_rails['smtp_domain'] = "mxhichina.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true

2、配置后需执行命令gitlab-ctl reconfigure重载配置文件

Running handlers:
Running handlers complete
Chef Client finished, 17/600 resources updated in 55 seconds
gitlab Reconfigured!

3、测试发送邮件验证SMTP配置,邮件发送成功表示配成正确。
    a)执行命令gitlab-rails console进入控制台

[root@izuf6fy69k7l7e20jogcj7z gitlab]# gitlab-rails console
-------------------------------------------------------------------------------------
 GitLab:       11.1.4 (63daf37)
 GitLab Shell: 7.1.4
 postgresql:   9.6.8
-------------------------------------------------------------------------------------
Loading production environment (Rails 4.2.10)
irb(main):001:0> 

    b)执行测试命令Notify.test_email(‘destination_email@address.com’, ‘Message Subject’, ‘Message Body’).deliver_now验证

irb(main):001:0> Notify.test_email('yvan.lu@ityww.cn','Testmail','test').deliver_now

Notify#test_email: processed outbound mail in 401.8ms

Sent mail to yvan.lu@ityww.cn (385.5ms)
Date: Wed, 08 Aug 2018 22:23:35 +0800
From: GitLab <postmaster@ityww.cn>
Reply-To: GitLab <noreply@gitlab.ityww.cn>
To: yvan.lu@ityww.cn
Message-ID: <5b7c2067b3fd_786c3fa07a1daf889661b@izuf6fy69k7l7e20jogcj7z.mail>
Subject: Testmail
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-html40/loose.dtd">
<html><body><p>test</p></body></html>

=> #<Mail::Message:69958105271780, Multipart: false, Headers: <Date: Wed, 08 Aug 2018 22:23:35 +0800>, <From: GitLab <postmaster@ityww.cn>>, <Reply-To: GitLab <noreply@gitlab.ityww.cn>>, <To: yvan.lu@ityww.cn>, <Message-ID: <5b7c2067b3fd_786c3fa07a1daf889661b@izuf6fy69k7l7e20jogcj7z.mail>>, <Subject: Testmail>, <Mime-Version: 1.0>, <Content-Type: text/html; charset=UTF-8>, <Content-Transfer-Encoding: 7bit>, <Auto-Submitted: auto-generated>, <X-Auto-Response-Suppress: All>>
irb(main):002:0>
更多邮箱配置请参考官方文档:https://docs.gitlab.com/omnibus/settings/smtp.html#smtp-settings

IT运维网 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明Gitlab 11.1.4 配置SMTP邮箱服务器
喜欢 (1)
[yvan.lu@ityww.cn]
分享 (0)
yvan
关于作者:
聪明来自勤奋、知识在于积累、好记性不如烂键盘!

您必须 登录 才能发表评论!